When i try to build the project i am getting this error (while deploying to heroku). Its my first Spring boot app and honestly i can't find any solution to this issue. My Jdk is v.17

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

EDIT:

Here is the build.gradle file configuration. Perhaps some dependency is not compatible?

plugins {id 'java-library'id 'org.springframework.boot' version '3.0.1'id 'io.spring.dependency-management' version '1.1.0'}group = 'com.example'version = '0.0.1-SNAPSHOT'sourceCompatibility = '17'repositories {mavenCentral()}dependencies {implementation 'org.springframework.boot:spring-boot-starter-data-jpa'implementation 'org.springframework.boot:spring-boot-starter-validation'implementation 'org.springframework.boot:spring-boot-starter-web'compileOnly 'org.projectlombok:lombok'runtimeOnly 'org.postgresql:postgresql'annotationProcessor 'org.projectlombok:lombok'testImplementation 'org.springframework.boot:spring-boot-starter-test'implementation group: 'com.opencsv', name: 'opencsv', version: '5.7.1'implementation group: 'org.modelmapper', name: 'modelmapper', version: '3.1.1'}tasks.named('test') {useJUnitPlatform()}
1

Best Answer


If you are using InteliJ you need to go to File > Settings > Build, Execution, Deployment > Build Tools > Gradle and change the Gradle JVM to be the 17.

Cheers