在Heroku中部署SpringBootAplication时遇到问题

时间:2020-08-07 20:16:07

标签: java spring spring-boot heroku

我正在使用meaven在我的机器上使用spring-boot编写一个api。但是,当我尝试在heroku上部署它时,出现了这个错误:

[INFO] -------------------------------------------------------------
       [ERROR] COMPILATION ERROR : 
       [INFO] -------------------------------------------------------------
       [ERROR] /tmp/build_6482326e_/src/main/java/com/XYZ/model/entity/Aclass.java:[4,15] package jdk.jfr does not exist
       [INFO] 1 error
       [INFO] -------------------------------------------------------------
       [INFO] ------------------------------------------------------------------------
       [INFO] BUILD FAILURE
       [INFO] ------------------------------------------------------------------------
       [INFO] Total time:  14.045 s
       [INFO] Finished at: 2020-08-07T20:03:49Z
       [INFO] ------------------------------------------------------------------------
       [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project XYZ: Compilation failure
       [ERROR] /tmp/build_6482326e_/src/main/java/com/XYZ/model/entity/Aclass.java:[4,15] package jdk.jfr does not exist
       [ERROR] -> [Help 1]
       [ERROR] 
       [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
       [ERROR] Re-run Maven using the -X switch to enable full debug logging.
       [ERROR] 
       [ERROR] For more information about the errors and possible solutions, please read the following articles:
       [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
 !     ERROR: Failed to build app with Maven
       We're sorry this build is failing! If you can't find the issue in application code,
       please submit a ticket so we can help: https://help.heroku.com/
 !     Push rejected, failed to compile Java app.
 !     Push failed

我正在本地使用Java 14。

我尝试在Google上搜索它,但是什么也没有。好吧,我希望有人知道该怎么做。谢谢。

1 个答案:

答案 0 :(得分:0)

所有给出的答案只是解决方法,此问题的真正答案是Heroku默认运行OpenJDK 8

如果希望Heroku使用其他Java版本,请在项目的根目录中添加一个名为system.properties的文件,并在此文件中为所选Java版本定义java.runtime.version属性。 / p>

例如:

java.runtime.version=14

您可以在此处阅读所有内容:

Supported java versions Heroku