Reputation: 1208
I am very new to STS. I searched for this error in stackoverflow. I didn't find correct matching answer.
I am able to see the class in MavenDependencies seciton in STS but not able to add the annotation in my java class.
Your help will be appriciated. Thanks
Upvotes: 24
Views: 81821
Reputation: 145
in Spring Tool Suite gradle > refresh gradle project should get it all working again
Upvotes: 0
Reputation: 1403
I had the same issue, but I am not sure if we got there for the same reason. In my case, the Spring Initializr generated my project with this tag on pom.xml file:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
But 3.0.0-SNAPSHOT doesn't even exist yet for this artifact. I went to the maven repository page, and I got the most recent one (currently 2.7.0), reloaded the project and it started working.
Upvotes: 0
Reputation: 1
import the following:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Upvotes: 0
Reputation: 499
Neither of the above solutions worked for me as my code was this
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<properties>
<java.version>1.8</java.version>
</properties>
I was missing the <dependencies>
tag which lead to this error.
Upvotes: 1
Reputation: 662
Clear your org/springframework/boot folder under .m2/ file location and run mvn clean install command under project
Upvotes: 0
Reputation: 4202
Go to your maven repository directory
For windows on below path
C:\Users\YourUser\.m2\repository\org\springframework\boot
Then delete spring-boot-autoconfigure
folder.
Now go to eclipse Right click on project -> Maven -> Update Project
.
This solved the problem for me.
Upvotes: 70
Reputation: 855
Run bellow commands from command line
mvn clean dependency:tree
mvn clean compile
select project and do a maven->update This solved my problem
Upvotes: 5
Reputation: 1
I had the same problem. You can resolve it with building the project with the "eclipse:eclipse"
goal.
Upvotes: -1
Reputation: 21
Just change your spring boot version into 1.5.6 from 1.5.8. trust me i have tried every other solution but only this solution worked for me.
Upvotes: 1
Reputation: 660
Add the import statement below your package declaration.
import org.springframework.boot.autoconfigure.SpringBootApplication;
You only need to add that annotation to your entry point, not every class. It goes on the same class that holds the main method to start Spring...
public static void main(String[] args) {
SpringApplication.run(CourseAPIApp.class, args);
}
Upvotes: 0