Gradle Build SpringBoot Project Failure

An Error confused me some days

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project ‘gradle-demo’.

Could not resolve all artifacts for configuration ‘:classpath’.
Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.1.7.RELEASE.
Required by:
project : > org.springframework.boot:org.springframework.boot.gradle.plugin:2.1.7.RELEASE
Could not resolve org.springframework.boot:spring-boot-gradle-plugin:2.1.7.RELEASE.
Could not parse POM https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-gradle-plugin/2.1.7.RELEASE/spring-boot-gradle-plugin-2.1.7.RELEASE.pom
Could not resolve org.springframework.boot:spring-boot-tools:2.1.7.RELEASE.
Could not resolve org.springframework.boot:spring-boot-tools:2.1.7.RELEASE.
Could not parse POM https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-tools/2.1.7.RELEASE/spring-boot-tools-2.1.7.RELEASE.pom
Could not resolve org.springframework.boot:spring-boot-parent:2.1.7.RELEASE.
Could not resolve org.springframework.boot:spring-boot-parent:2.1.7.RELEASE.
Could not parse POM https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-parent/2.1.7.RELEASE/spring-boot-parent-2.1.7.RELEASE.pom
Could not resolve org.springframework.boot:spring-boot-dependencies:2.1.7.RELEASE.
Could not resolve org.springframework.boot:spring-boot-dependencies:2.1.7.RELEASE.
Could not parse POM https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-dependencies/2.1.7.RELEASE/spring-boot-dependencies-2.1.7.RELEASE.pom
Could not resolve org.springframework.data:spring-data-releasetrain:Lovelace-SR10.
Could not resolve org.springframework.data:spring-data-releasetrain:Lovelace-SR10.
Could not get resource ‘https://plugins.gradle.org/m2/org/springframework/data/spring-data-releasetrain/Lovelace-SR10/spring-data-releasetrain-Lovelace-SR10.pom’.
Could not HEAD ‘https://repo.jfrog.org/artifactory/libs-release-bintray/org/springframework/data/spring-data-releasetrain/Lovelace-SR10/spring-data-releasetrain-Lovelace-SR10.pom?referrer’.
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

The build.gradle is

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

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
	mavenCentral()
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-web'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

Thanks for anyone give help!!

The last error message is related to a problem verifying certificates for secure connection.

  1. Can you access other links that Gradle complains about, from the browser? For example, the first link
    https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-gradle-plugin/2.1.7.RELEASE/spring-boot-gradle-plugin-2.1.7.RELEASE.pom
    Works for me and downloads the pom file.
  2. Are you behind a firewall? It might be blocking the connection.
  3. This knowledge base article from JFrog refers to this error when happen on a machine running Artifactory. You can try applying the solution of adding the required certificate.