java - 如何修复 spring-boot-gradle-plugin :3. 0.0 问题?

标签 java spring spring-boot heroku spring-boot-gradle-plugin

我正在部署spring boot Heroku 上的应用程序使用 gitlab ci/cd

我正在使用spring boot 3.0.0java 17

有人知道怎么解决吗? 同样在第 8 行,它是 -----> Installing OpenJDK 1.8... done我不知道为什么以及如何即使我在应用程序中有 java 17

Deploying application
uploading application archive
triggering new deployment
-----> Building on the Heroku-22 stack
-----> Determining which buildpack to use for this app
-----> Gradle app detected
-----> Spring Boot detected
-----> Installing OpenJDK 1.8... done
-----> Building Gradle app...
-----> executing ./gradlew build -x check
       Downloading https://services.gradle.org/distributions/gradle-7.5.1-bin.zip
       ...........10%............20%...........30%............40%...........50%............60%...........70%............80%...........90%............100%
       To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.5.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
       Daemon will be stopped at the end of the build 
       
       FAILURE: Build failed with an exception.
       
       * What went wrong:
       A problem occurred configuring root project 'auth'.
       > Could not resolve all files for configuration ':classpath'.
          > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.0.
            Required by:
                project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.0
             > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.0 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.5.1' but:
                 - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a library, packaged as a jar, and its dependencies declared externally:
                     - 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 8
                     - Other compatible attribute:
                         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5.1')
                 - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a runtime of a component, 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 '7.5.1')
                 - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.0 declares a library, packaged as a jar, and its dependencies declared externally:
                     - 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 8
                     - Other compatible attribute:
                         - Doesn't say anything about org.gradle.plugin.api-version (required '7.5.1')
                 - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.0 declares a runtime of a library, 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 '7.5.1')
                 - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a runtime of a library, 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 '7.5.1')
                 - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a runtime of a component, 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 '7.5.1')
       
       * 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
       
       BUILD FAILED in 9s
 !     ERROR: Failed to run Gradle!
       We're sorry this build is failing. If you can't find the issue in application
       code, please submit a ticket so we can help: https://help.heroku.com
       You can also try reverting to the previous version of the buildpack by running:
       $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-gradle#previous-version
       
       Thanks,
       Heroku

最佳答案

您可能在本地使用 Java 17,但在 Heroku 上您使用的是 Java 8。 This is the default :

Heroku currently uses OpenJDK 8 to run your application by default. Other OpenJDK versions are also available. Depending on the OpenJDK version you select the latest available version of that JDK will be used each time you deploy your app.

您需要explicitly request the correct version of Java 。将名为 system.properties 的文件添加到项目的根目录,其中包含

java.runtime.version=17

然后提交并重新部署。

关于java - 如何修复 spring-boot-gradle-plugin :3. 0.0 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74595549/

相关文章:

java - JTextArea 无法在多线程中工作 - java

java - Spring @Autowired - 后台发生了什么

java - org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'sessionFactory' defined in ServletContexoller':

postgresql - 带有 Hikari 的 Spring JPA 不释放连接

java - 如何获取两个日期之间的数据 REST Spring

Java 生成彩虹色 - 怎么样?

java - JPA:自己的注释来为具有相同值的字段捆绑注释

java - 在 Hibernate 中,为什么 Set 是表示多值关联的推荐方式

spring - spring-integration 中具有基本身份验证的出站网关

java - 在 Spring Boot 应用程序中从 mongo db 获取数据,其中要获取的集合名称和字段在运行时已知