SpringBootApplication
IntelliJ IDEA
Java
Error Resolution
Spring Boot
Cannot resolve symbol 'SpringBootApplication' in IntelliJ IDEA
Codemia Knowledge Hub ·
Cannot resolve symbol 'SpringBootApplication' means IntelliJ IDEA cannot find the Spring Boot starter libraries on your project's classpath. Usually the dependency is missing from the build file, or IntelliJ has not imported it yet.
What @SpringBootApplication is
@SpringBootApplication is a convenience annotation that combines three others:
@Configuration: tags the class as a source of bean definitions for the application context.@EnableAutoConfiguration: tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings.@ComponentScan: tells Spring to scan the package to find other beans, controllers, and services.
Missing Spring Boot dependencies
The most common cause is that the Spring Boot dependencies are not in pom.xml (Maven) or build.gradle (Gradle).
- Maven: make sure
pom.xmlincludes the correct Spring Boot starter dependencies. - Gradle: make sure the Spring Boot starter is included in
build.gradle.
Fixes inside IntelliJ
- Re-import the project. For Maven, right-click
pom.xmland select "Maven" -> "Reload Project". For Gradle, use the "Refresh" button in the Gradle tool window. - Invalidate caches. Go to
File->Invalidate Caches / Restart...->Invalidate and Restart. - Mark the source folder. Right-click the
srcfolder ->Mark Directory as->Sources Root. - Check the JDK. Go to
File->Project Structure->Projectand select a JDK version compatible with your Spring Boot version. - Rebuild. Use
Build->Rebuild Project.
Preventing it next time
- Keep dependencies updated: use the latest compatible versions to reduce compatibility issues.
- Update IntelliJ: IDE bugs are sometimes fixed in later versions.
- Check build files: make sure they have no syntax or logic errors that stop the build tool from reading them.
Related reading
- Can't Autowire Repository annotated interface in Spring Boot
- Cant autowire WebTestClient - no auto configuration
- Can't avoid hibernate logging SQL to console with Spring Boot and Logback
- Can't compile project when I'm using Lombok under IntelliJ IDEA
- Cannot return null for non-nullable type 'Person' within parent 'Messages' /getMessages/sendBy in GraphQL SDL aws appsync
- Cannot run tensorflow on GPU
- Can't create handler inside thread that has not called Looper.prepare()
- Can't execute jar- file 'no main manifest attribute

Course
Intermediate
27 lessons
14 hours
OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.