mephisto_mori
mephisto_mori

Reputation: 313

IntelliJ: Spring annotations are not recognized/Do not trigger auto-import. Manual import works

I created a new Spring project in IntelliJ Ultimate 2019.2 via the Spring Initializr as a Maven Project and when I try to annotate any of my classes with Spring annotations IntelliJ does not recognize them ("Cannot resolve symbol 'Controller'"). The pom has the relevant dependencies and if I manually import the class the annotation is recognized.

I tried finding a solution online but from what I could tell there is noone else with this specific problem.

To fulfill the requirement of this being a question: How do I configure IntelliJ/Maven/Spring or whatever my be responsible for this mishap to appropriately show and import the respective Spring classes?

Upvotes: 2

Views: 13739

Answers (3)

OhadR
OhadR

Reputation: 8839

right click the project name -> Maven -> Sync Project

enter image description here

Upvotes: 0

Olga Klisho
Olga Klisho

Reputation: 1394

Please check the following settings: Preferences | Editor | General | Auto Import | Exclude from import and completion list. In case import becomes resolved after you type it manually, but not suggested/completed by IntelliJ IDEA, probably you've added some of the Spring libs to the exclusion list.

Upvotes: 1

Madhu Potana
Madhu Potana

Reputation: 91

  1. Have you check spring dependencies added in POM.
  2. Needs add this anotations @EnableAutoConfiguration, @SpringBootApplication in the main class.
  3. check .m2 folder and class path lib wther all jar downloaded or not.
  4. Check once Controller.class is available or not, in eclipse we use the command ctrl+t.
  5. Try take any spring boot example from github and import into inteliJ

Upvotes: 2

Related Questions