【问题标题】:Heroku unable to detect java 11Heroku 无法检测到 java 11
【发布时间】:2020-06-25 00:17:14
【问题描述】:

我正在尝试使用 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 版本设置为 11 ?我也尝试将 ${java.version} 添加到配置中,但没有帮助

【问题讨论】:

    标签: java heroku


    【解决方案1】:

    这正是您指定 Java 版本的方式,请参阅:https://devcenter.heroku.com/articles/java-support#specifying-a-java-version

    您可以通过添加一个名为 system.properties 到您的应用程序。

    在文件中设置属性java.runtime.version

    java.runtime.version=11
    

    我也在my project 中使用过它,它正在工作。


    确保您的system.properties 保存为All Files。此外,它应该位于您的 git repo 的根文件夹中。
    它可能有一个.txt 结尾。如果失败了open a Support Ticket with Heroku

    【讨论】:

    • 我发现了问题-它与 git push heroku master 的命令解释有关,我有一个功能分支,我在其中进行了所有更改并试图盲目地执行 master.- 所以将其更改为功能和它选择了 java 11
    猜你喜欢
    • 2016-10-10
    • 2017-01-10
    • 2015-10-06
    • 2016-06-22
    • 1970-01-01
    • 1970-01-01
    • 2016-10-30
    • 2020-11-28
    • 2016-12-04
    相关资源
    最近更新 更多