๐Ÿ”ด The Error You're Seeing

Confirm this matches your console output. If it does, you're in the right place.

ERROR LOG> Task :compileJava FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileJava'. > Could not resolve all files for configuration ':compileClasspath'. > Could not resolve org.springframework.boot:spring-boot-starter-web. Required by: project :

โšก Quick Fix Works 80% of the time

Ensure `mavenCentral()` is in the `repositories` block in `build.gradle`.

repositories { mavenCentral() }

๐Ÿง  Why this Happens

Tap to expand the deep technical explanation

Gradle tried to download a Spring Boot starter dependency, but couldn't find it. This happens if the `repositories` block is missing `mavenCentral()`, or if the `spring-boot-gradle-plugin` is not applied correctly in the `plugins` block.

The HITEC City Parking Spot Analogy:

It's like sending a procurement officer to buy supplies, but forgetting to tell them which store to go to. They come back empty-handed because they didn't know to visit the central warehouse (mavenCentral).

๐Ÿ” How to Reproduce Confirm this is your error

Create a `build.gradle` file. Add `implementation 'org.springframework.boot:spring-boot-starter-web'` to dependencies. Remove `mavenCentral()` from the repositories block. Run `gradle build`.

๐Ÿ› ๏ธ Solutions (5 Ways to Fix)

Solution 1โœ“ Most common cause

Add mavenCentral() to repositories

๐Ÿ‘‰ Use this if you are new to Gradle and forgot the repository block.

Gradle needs to know where to download dependencies from. `mavenCentral()` points to the global Maven repository.

repositories { mavenCentral() }
Solution 2

Apply the Spring Boot Gradle Plugin

๐Ÿ‘‰ Use this if the plugin is missing from the `plugins` block.

The plugin manages Spring Boot's dependency versions and build lifecycle.

plugins { id 'java' id 'org.springframework.boot' version '3.2.0' id 'io.spring.dependency-management' version '1.1.4' }
Solution 3

Refresh Gradle Project

๐Ÿ‘‰ Use this if you added the dependency but the IDE still complains.

IntelliJ caches Gradle dependencies. You must manually trigger a sync to download the new JARs.

// Right-click build.gradle -> Gradle -> Refresh Gradle Project // Or run in terminal: gradle --refresh-dependencies build
Solution 4

Check for offline mode

๐Ÿ‘‰ Use this if you are traveling or disconnected from the internet.

If Gradle is set to offline mode, it only looks in the local cache. Disable offline mode in your IDE.

// IntelliJ: View -> Tool Windows -> Gradle // Toggle the 'Toggle Offline Mode' button (should be unselected)
Solution 5

Configure corporate proxy

๐Ÿ‘‰ Use this if you are behind a corporate firewall.

If your network blocks Maven Central, you must configure the proxy in `gradle.properties`.

# gradle.properties systemProp.http.proxyHost=proxy.mycompany.com systemProp.http.proxyPort=8080 systemProp.https.proxyHost=proxy.mycompany.com systemProp.https.proxyPort=8080

๐Ÿ“‹ Version Notes

Spring Boot 2.x

Uses older Gradle plugin versions.

Spring Boot 3.x

Requires Gradle 7.5+ and Java 17.

๐Ÿ›ก๏ธ How to Prevent This Next Time

Use Spring Initializr to generate your `build.gradle` file to ensure the `plugins` and `repositories` blocks are correctly configured from day one.

Course Search
Search across all chapters & stages
๐Ÿ“–

Search the course

Type any topic โ€” branching, stash, rebase, hooks โ€” and jump straight to that chapter.

merge branchesgit stashundo commitrebase