在我的 spring-maven-java 项目上使用 git push heroku master
时,Heroku cli 识别出它是一个 Java 项目并尝试构建它。它打印出它正在安装JDK 1.8,并且在多次终端输出后显示[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:在项目 myProject 上编译(默认编译):编译 fatal error :目标版本无效:10.0.2
maven-compiler-plugin 配置源和目标明确标识了 Heroku 文档指定的可接受的 Java 10.0.2,并且 java.runtime.version=10.0.2
均位于 application.properties
和 system.properties
我想我需要让 Heroku 在开始时安装正确的 JDK。如何让 Heroku 获取并使用 Java 10?
请参阅我尝试修改的程度 maven-compiler-plugin
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>10.0.2</source>
<target>10.0.2</target>
<release>10.0.2</release>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
最佳答案
在应用的根目录中创建一个 system.properties
文件,并将以下内容放入其中:
java.runtime.version=10.0.2
将其提交到 Git 并再次推送。欲了解更多信息,请参阅Heroku'd Dev Center .
关于java - 当我明确告知 Heroku 时,为什么 Heroku 无法识别正确的 Java 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53923414/