【问题标题】:Why isn't Heroku recognising the correct Java version when I've told it explicitly?当我明确告诉 Heroku 时,为什么 Heroku 不能识别正确的 Java 版本?
【发布时间】:2019-05-24 04:56:59
【问题描述】:

在我的 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:compile (default-compile) on project myProject: Fatal error compiling: invalid target release: 10.0.2

maven-compiler-plugin 配置源和目标将 Java 10.0.2 明确标识为 Heroku 文档指定的可接受,java.runtime.version=10.0.2 位于 application.propertiessystem.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>

【问题讨论】:

  • stackoverflow.com/questions/53604111/… 我的线程,还没有弄明白,我尝试了很多东西,没有任何效果。它必须是别的东西。
  • @valkon 在我的例子中 system.properties 是在 src 目录而不是根/最高级别的目录

标签: java heroku heroku-cli


【解决方案1】:

在你的应用根目录下创建一个system.properties文件,并在其中放入以下内容:

java.runtime.version=10.0.2

将其提交给 Git 并再次推送。欲了解更多信息,请参阅Heroku'd Dev Center

【讨论】:

  • 谢谢,我现在有一个不同的问题,但是将我的 system.properties 文件从 resources 移动到根目录/最高级别的目录已经修复了 JDK 并使 Heroku 运行应用程序
  • 我假设system.properties 会和application.properties 出现在同一个地方,即recomended to go in src/main/resources
猜你喜欢
  • 1970-01-01
  • 2015-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-11
  • 1970-01-01
  • 1970-01-01
  • 2020-02-25
相关资源
最近更新 更多