Problem Deploying SpringBootAplication of Heroku

huangapple go评论71阅读模式
英文:

Problem Deploying SpringBootAplication of Heroku

问题

在我的机器上,我正在使用Spring Boot编写API,使用Maven构建工具,它能够正常运行。但当我尝试在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上搜索了这个问题,但没有找到解决方法。希望有人知道该如何处理。谢谢。

英文:

I'm coding a api with spring-boot, using meaven, in my machine it runs. But when I tried to deploy it on heroku it gave me this error:

[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

I am using Java 14 locally.

I tried searching it on google, but nothing. Well, I hope someone knows what to do. Thanks.

答案1

得分: 0

所有给出的答案都只是一种变通方法,这个问题的真正答案是,Heroku默认运行OpenJDK 8

如果您希望Heroku使用不同的Java版本,您需要在项目的根目录中添加一个名为system.properties的文件,在这个文件中定义java.runtime.version属性为所选的Java版本。

例如:

java.runtime.version=14

您可以在这里阅读有关此内容的详细信息:

Heroku支持的Java版本

英文:

All given answers are just workarounds, the real answer to this question is that Heroku runs per default OpenJDK 8

if you wish Heroku to use a different java version you add a file named system.properties in the root of the project, and in this file you define the java.runtime.version property to the selected java version.

For example:

java.runtime.version=14

you can read all about it here:

Supported java versions Heroku

huangapple
  • 本文由 发表于 2020年8月8日 04:16:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/63308651.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定