Cva*_*nzy 11 java heroku maven
这是我在github上的代码:https : //github.com/q463746583/CS4500-Assignment2 我可以在本地成功运行,但是当我尝试在heroku上部署代码时,出现错误描述:
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/2.0-M9/qdox-2.0-M9.jar (317 kB at 6.0 MB/s)
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /tmp/build_3c4f3b86a26f6e3ae1cbe89639f79f26/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.261 s
[INFO] Finished at: 2019-01-24T00:47:07Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project myapp: Fatal error compiling: invalid target release: 11 -> [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/MojoExecutionException
! 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
Run Code Online (Sandbox Code Playgroud)
Nat*_*han 12
我认为这与Heroku 上的目标 Java 运行时环境与从 Maven 编译器生成的本地编译代码之间的不匹配有关,您正试图将其推送到 Heroku。
根据 Heroku 的文档:
Heroku 当前默认使用OpenJDK 8 来运行您的应用程序。OpenJDK 版本 9 和 7 也可用。
其他支持的默认版本是:
因此,您应该确保在您的pom.xml文件中,您的maven 编译器正在将您的 JAVA 代码编译为您在 Heroku 上针对的相应 JAVA buildpack。例如,下面我们针对的是 Java 7 运行时环境:
pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
如果您的目标是 Heroku 的默认 JDK 1.8运行时环境以外的运行时环境,那么您应该在项目中创建一个system.properties文件。您可以通过指定所需的 Java 运行时环境来执行此操作,如下所示:
系统属性:
java.runtime.version=11
Run Code Online (Sandbox Code Playgroud)
域名注册地址:
希望有帮助
| 归档时间: |
|
| 查看次数: |
3961 次 |
| 最近记录: |