Spring Boot
Java
Error Resolution
Maven
Dependency Management

package org.springframework.boot does not exist

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

The compiler error package org.springframework.boot does not exist means your project is trying to import Spring Boot classes, but the Boot libraries are not on the compile classpath. In practice, that usually comes down to missing dependencies, a broken build import, or an IDE that has not synchronized the project correctly.

Start with the Build File

For Maven, a minimal Spring Boot project typically needs the Boot parent or dependency management plus at least one starter dependency.

xml
1<project xmlns="http://maven.apache.org/POM/4.0.0">
2  <modelVersion>4.0.0</modelVersion>
3
4  <parent>
5    <groupId>org.springframework.boot</groupId>
6    <artifactId>spring-boot-starter-parent</artifactId>
7    <version>3.3.2</version>
8    <relativePath/>
9  </parent>
10
11  <groupId>com.example</groupId>
12  <artifactId>demo</artifactId>
13  <version>0.0.1-SNAPSHOT</version>
14
15  <dependencies>
16    <dependency>
17      <groupId>org.springframework.boot</groupId>
18      <artifactId>spring-boot-starter-web</artifactId>
19    </dependency>
20  </dependencies>
21</project>

If the Boot starter dependency is missing, imports such as org.springframework.boot.SpringApplication will not resolve.

Gradle Needs the Same Basic Idea

For Gradle, the build must also apply the relevant plugin and dependencies.

gradle
1plugins {
2    id 'java'
3    id 'org.springframework.boot' version '3.3.2'
4    id 'io.spring.dependency-management' version '1.1.6'
5}
6
7repositories {
8    mavenCentral()
9}
10
11dependencies {
12    implementation 'org.springframework.boot:spring-boot-starter-web'
13    testImplementation 'org.springframework.boot:spring-boot-starter-test'
14}

If the plugin or dependency block is incomplete, the package will still appear missing even if the source code itself is fine.

Verify Dependency Resolution Outside the IDE

Before blaming IntelliJ or Eclipse, confirm that the build tool resolves dependencies from the command line.

For Maven:

bash
mvn dependency:tree
mvn compile

For Gradle:

bash
gradle dependencies
gradle build

If the command-line build fails, the problem is in the project setup, not the IDE view of the project.

Common Causes

The usual causes are:

  • missing Spring Boot dependency in pom.xml or build.gradle
  • missing repository configuration such as mavenCentral()
  • corrupted local dependency cache
  • incorrect project import in the IDE
  • trying to compile a plain Java project that was never configured as Boot at all

These are classpath problems first, not Java syntax problems. Proxy or mirror misconfiguration can also block Maven or Gradle from downloading the artifacts, which produces the same missing-package symptom from the compiler's point of view.

IDE Sync Still Matters

Sometimes the build file is correct but the IDE has stale metadata. In that case:

  • reimport the Maven or Gradle project
  • invalidate IDE caches if the model is clearly stale
  • verify the project SDK and language level

A correct build file with an out-of-sync IDE can still show the same missing-package error in the editor. That is why checking both the command-line build and the IDE model is worth the extra minute.

Confirm the Import You Expect

A small sanity check helps:

java
1import org.springframework.boot.SpringApplication;
2import org.springframework.boot.autoconfigure.SpringBootApplication;
3
4@SpringBootApplication
5public class DemoApplication {
6    public static void main(String[] args) {
7        SpringApplication.run(DemoApplication.class, args);
8    }
9}

If this still fails after dependency resolution and project sync, the project classpath is not actually including Spring Boot yet.

Common Pitfalls

The most common mistake is adding Spring Framework dependencies but forgetting that Spring Boot classes live in Boot-specific artifacts.

Another mistake is editing the build file but never reimporting the project in the IDE.

It is also easy to assume the IDE error is authoritative when the command-line build has not been checked at all.

Summary

  • The error means Spring Boot libraries are missing from the compile classpath.
  • Fix the build file first, then verify dependency resolution from the command line.
  • Reimport the project in the IDE after changing Maven or Gradle configuration.
  • A correct Spring Boot starter dependency is usually the key missing piece.
  • Treat this as a classpath and build configuration problem, not a source-code syntax problem.

Course illustration
Course illustration

All Rights Reserved.