๐ด The Error You're Seeing
Confirm this matches your console output. If it does, you're in the right place.
> 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)
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()
}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'
}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 buildCheck 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)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
Uses older Gradle plugin versions.
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.