Table of contents

Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE.

Java Aug 29, 2021 Viewed 1.9K Comments 0

Issue

I opened the Java project with Intellij IDEA, and there was an error when compiling. It was fine before, and the error is as follows:

Starting Gradle Daemon...
Gradle Daemon started in 3 s 566 ms

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'demo'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE.
     Required by:
         project : > org.springframework.boot:org.springframework.boot.gradle.plugin:2.2.2.RELEASE
      > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE.
         > Could not get resource 'https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-gradle-plugin/2.2.2.RELEASE/spring-boot-gradle-plugin-2.2.2.RELEASE.pom'.
            > Could not HEAD 'https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-gradle-plugin/2.2.2.RELEASE/spring-boot-gradle-plugin-2.2.2.RELEASE.pom'.
               > Connect to plugins.gradle.org:443 [plugins.gradle.org/104.18.191.9, plugins.gradle.org/104.18.190.9, plugins.gradle.org/2606:4700:0:0:0:0:6812:be09, plugins.gradle.org/2606:4700:0:0:0:0:6812:bf09] failed: No route to host (connect failed)
   > Could not resolve io.spring.gradle:dependency-management-plugin:1.0.8.RELEASE.
     Required by:
         project : > io.spring.dependency-management:io.spring.dependency-management.gradle.plugin:1.0.8.RELEASE
      > Could not resolve io.spring.gradle:dependency-management-plugin:1.0.8.RELEASE.
         > Could not get resource 'https://plugins.gradle.org/m2/io/spring/gradle/dependency-management-plugin/1.0.8.RELEASE/dependency-management-plugin-1.0.8.RELEASE.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/io/spring/gradle/dependency-management-plugin/1.0.8.RELEASE/dependency-management-plugin-1.0.8.RELEASE.pom'.
               > Connection reset

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

CONFIGURE FAILED in 3m 25s

My build.gradle has few dependencies of sprint boot.

plugins {
    id 'org.springframework.boot' version '2.2.2.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'
}

sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter")
    implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
    ....
}

Solution

Add the following repository. org.springframework.boot:org.springframework.boot.gradle.plugin not available in maven central:

repositories {
    mavenCentral()
    maven {
        url "https://plugins.gradle.org/m2/"
    }
}

Rebuild finally.

Updated Aug 29, 2021