Suraj Bhagat
Suraj Bhagat

Reputation: 21

Gradle build is getting failed when i tried to build a spring boot project

A problem occurred configuring root project 'Task_Manager '.

Could not resolve all files for configuration ':classpath'. Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.1.1. Required by: project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.1.1 > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.1.1 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.1.1' but: - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.1 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.1') - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.1 declares a component for use during runtime, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.1') - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.1.1 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.1') - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.1.1 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.1') - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.1 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.1') - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.1 declares a component for use during runtime, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.1')

Upvotes: 2

Views: 1006

Answers (1)

desa
desa

Reputation: 196

For ref: I'm using VS Code on a MacBook 2020. Using id 'org.springframework.boot' version '2.7.13'.

I just had the same issue. I solved it by creating a gradle.properties file in the root of the project and adding this:

org.gradle.java.home=<myPathTo>openjdk@17/17.0.7/libexec/openjdk.jdk/Contents/Home/

Afterwards, I made sure that port :8080 was available, and then I succeeded running gradle bootRun / or executing it using the extension in VSCode.

Between every change I did, I ran the build.clean task which made it clear for me that port 8080 was occupied.


For 'org.springframework.boot' version '3.1.1' I followed a combination of the answer from Vifeng in this link and my answer above.

Upvotes: 0

Related Questions