我正在尝试使用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 verison设置为11?我也尝试过将$ {java.version}添加到配置中,但没有帮助
答案 0 :(得分:1)
这正是您指定Java版本的方式,请参见:https://devcenter.heroku.com/articles/java-support#specifying-a-java-version
您可以通过添加一个名为的文件来指定Java版本
system.properties
移至您的应用程序。在文件中设置属性
java.runtime.version
:java.runtime.version=11
我也在my project中使用了它,并且它正在工作。
确保将您的system.properties
保存为All Files
。此外,它应该位于git仓库的根文件夹中。
它的结尾可能为.txt
。如果失败,open a Support Ticket with Heroku。