我正在尝试使用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>
Run Code Online (Sandbox Code Playgroud)
当我执行 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
Run Code Online (Sandbox Code Playgroud)
最终构建失败并出现错误:
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 ->
Run Code Online (Sandbox Code Playgroud)
如何将jdk版本设置为11?我也尝试将 ${java.version} 添加到配置中,但没有帮助
这正是指定 Java 版本的方式,请参阅: https: //devcenter.heroku.com/articles/java-support#specifying-a-java-version
您可以通过添加一个调用到您的应用程序的文件来指定 Java 版本
system.properties。
java.runtime.version在文件中设置属性:Run Code Online (Sandbox Code Playgroud)java.runtime.version=11
我也在我的项目中使用了它并且它正在工作。
确保你的system.properties保存为All Files. 此外,它应该位于 git 存储库的根文件夹中。
它可能有一个.txt结局。如果失败,请使用 Heroku 打开支持票。