heroku - system.properties和java版本

时间:2013-11-17 19:14:50

标签: java maven heroku

我想将我的java 7应用程序部署到Heroku但是我遇到了java版本的一些问题。

我在项目根目录(system.propertiessrc中)添加了pom.xml文件,内容为java.runtime.version=1.7,但我仍然得到这样的内容:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project lets-code: Fatal error compiling: invalid target release: 1.7

所以我对下一步该做什么感到困惑。

2 个答案:

答案 0 :(得分:7)

Heroku上的Java默认版本是Java 6.您需要按照Guidelines使您的maven项目在较新版本的JVM(1.7或1.8)上运行。您已将system.properties文件添加到项目中。但是,您可能没有按照指定更新PATH,并且maven尝试使用OpenJDK 6构建您的应用程序,这会导致无效的目标释放异常。

更新PATH应该可以解决问题。

答案 1 :(得分:1)

我使用了以下指南https://devcenter.heroku.com/articles/customizing-the-jdk

指定JDK版本 如果尚不存在,请创建一个system.properties文件,指定版本并将其提交到git。 Java支持文章中介绍了受支持的版本。该文件的内容应如下所示:

java.runtime.version = 11 然后通过运行将文件添加到Git:

git添加system.properties git commit -m“ JDK 11”

对我有用。