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.xml includes 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.xml and 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 src folder -> Mark Directory as -> Sources Root.
  • Check the JDK. Go to File -> Project Structure -> Project and 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.

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 course
Data 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.

Practice algorithms