Reputation: 8548
I have a Spring Boot project that I just migrated from Spring Boot 2.7 to 3.2, and I also had to change it from JDK 11 to JDK 17. It builds and runs fine within Intellj IDEA.
When I go to the terminal and run ./gradlew build
to get an executable jar, it fails to build and looks like it's trying to use JDK 11 still, and also an older Kotlin version.
Could not resolve all files for configuration ':classpath'.
Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.2.
Required by:
project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.2.2
> No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.2.2 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribu te 'org.gradle.plugin.api-version' with value '7.4.1' but:
./gradlew --version
outputs:
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 11.0.13 (JetBrains s.r.o. 11.0.13+0-b1751.21-8125866)
Where is it getting these old versions from? Kotlin is 1.9.22 in my build.gradle, and Java Version is 17.
Upvotes: 0
Views: 804
Reputation: 244
Gradle will try to find the java executable under JAVA_HOME
folder and use it if it exists. If not exist, it will try to use the default java
command. So either your JAVA_HOME
is pointing to a java version 11 folder or your default java
in cmd is using java 11. Try using update-java-alternatives
command to point java
command to java 17.
Upvotes: 1