Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@SpringBootApplication cannot be resolved to a type In STS

Tags:

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.

enter image description here Your help will be appriciated. Thanks

enter image description here

like image 893
Abdul Avatar asked Jan 16 '17 02:01

Abdul


People also ask

Which annotation can be used to replace @SpringBootApplication?

@SpringBootApplication is a alternative for @Configuration , @EnableAutoConfiguration and @ComponentScan . Probably you want use @Configuration + @ComponentScan . If you want load xml configuration you can use: @ImportResource annotation.

What is @SpringBootApplication annotation in spring boot?

Spring Boot @SpringBootApplication annotation is used to mark a configuration class that declares one or more @Bean methods and also triggers auto-configuration and component scanning. It's same as declaring a class with @Configuration, @EnableAutoConfiguration and @ComponentScan annotations.

Can we have 2 classes with @SpringBootApplication?

So yes, this is expected behavior given your project setup. Put each @SpringBootApplication class in a separate subpackage if you don't want this to happen for local testing.


1 Answers

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.

like image 171
Foolish Avatar answered Oct 03 '22 15:10

Foolish