gpt4 book ai didi

java - Heroku 无法检测到 java 11

转载 作者:行者123 更新时间:2023-12-01 17:59:27 24 4
gpt4 key购买 nike

我正在尝试使用heroku maven插件将java jar部署到heroku。我使用的是 java 11,因此我在根文件夹(其中存在 pom.xml)中添加了 system.properties 并设置 java.runtime.version=11。但它似乎不起作用!

我的插件:

            <plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<includeTarget>false</includeTarget>
<includes>
<include>${project.build.directory}/${project.build.finalName}.jar</include>
</includes>
<processTypes>
<web>java $JAVA_OPTS -jar ${project.build.directory}/${project.build.finalName}.jar</web>
</processTypes>
</configuration>
</plugin>

当我执行 git push heroku master 时,它会使用 jdk 8 开始构建过程。


remote: Building source:
remote:
remote: -----> Java app detected
remote: -----> Installing JDK 1.8... done
remote: -----> Installing Maven 3.6.2... done
remote: -----> Executing Maven
remote: $ mvn -DskipTests clean dependency:list install

最终构建失败并出现错误:

 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project ImpactHub_bot: Fatal error compiling: invalid flag: --release -> 

如何将 jdk 版本设置为 11 ?我也尝试将 ${java.version} 添加到配置中,但没有帮助

最佳答案

这正是指定 Java 版本的方式,请参阅:https://devcenter.heroku.com/articles/java-support#specifying-a-java-version

You can specify a Java version by adding a file called system.properties to your application.

Set a property java.runtime.version in the file:

java.runtime.version=11

我在my project中使用过它以及它正在工作。

<小时/>

确保您的system.properties保存为所有文件。此外,它应该位于 git 存储库的根文件夹中。
它可能以 .txt 结尾。如果失败 open a Support Ticket with Heroku .

关于java - Heroku 无法检测到 java 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60662711/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com