【问题标题】:HEROKU use -source 7 or higher to enable diamond operatorHEROKU 使用 -source 7 或更高版本来启用钻石运算符
【发布时间】:2018-09-29 05:07:26
【问题描述】:

我尝试部署在 Java EE 平台上构建的应用程序。当我运行命令git push heroku master 时,在部署结束时,会生成许多错误。

主要的例外是:use -source 7 or higher to enable diamond operator

有人知道这个错误吗?贝娄是更多错误消息。 如果你能帮助我,谢谢。

[ERROR] -> [Help 1]
remote:        [ERROR] 
remote:        [ERROR] To see the full stack trace of the errors, re-run 
Maven with the -e switch.
remote:        [ERROR] Re-run Maven using the -X switch to enable full 
debug logging.
remote:        [ERROR] 
remote:        [ERROR] For more information about the errors and possible 
solutions, please read the following articles:
remote:        [ERROR] [Help 1]                         
http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
remote: 
remote:  !     ERROR: Failed to build app with Maven
remote:        We're sorry this build is failing! If you can't find the 
issue in application code,
remote:        please submit a ticket so we can help: 
https://help.heroku.com/
remote: 
remote:  !     Push rejected, failed to compile Java app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to wiidas-jee.

【问题讨论】:

  • 来自Oracle's documentation of javac: javac -source 1.7(或您需要的任何源版本)
  • 嗨@Turing85。但是我的编译环境是1.8。见下文:openjdk version "1.8.0_162" OpenJDK Runtime Environment (build 1.8.0_162-8u162-b12-1~deb9u1-b12) OpenJDK 64-Bit Server VM (build 25.162-b12, mixed mode)
  • 是的。在您的 pom.xml 中指定源兼容性(请不要问我如何 - 我不使用 maven)。这样,您可以确保始终以指定的源兼容性编译您的源代码。问题不在您的本地站点,而是在 herokus 端(远程编译失败)。
  • 必须配置maven-compiler-plugin。
  • @Turing85 和 Thorbjørn Ravn Andersen。谢谢你帮助我!在阅读了有关如何在 Heroku 中设置 Maven 的更多信息后,我找到了解决方案!添加codefinger的响应的xml标签(还有一些修改)。

标签: java git maven heroku jakarta-ee


【解决方案1】:

将以下插件和配置添加到您的pom.xml

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
    </configuration>
</plugin>

然后运行:

$ git add pom.xml
$ git commit -m "pom.xml"
$ git push heroku master

【讨论】:

  • 嗨@codefinger!您的回复对我的解决方案非常重要。粘贴此标签后,提交并推送,构建不起作用。但是,我搜索了生成的异常,并将 maven 的版本更改为 3.8.2。在此之后,他的构建工作完美。谢谢。
  • 远程:[INFO] 建立成功远程:[INFO] ------------------------------ ------------------------ 远程:[INFO] 总时间:02:11 分钟远程:[INFO] 完成于:2018-04-19T13: 45:48+00:00 远程:[INFO] 最终内存:38M/402M 远程:[INFO] --------------------------- --------------------------
猜你喜欢
  • 1970-01-01
  • 2018-04-22
  • 2014-05-21
  • 2015-05-29
  • 1970-01-01
  • 1970-01-01
  • 2014-09-28
  • 2018-01-18
  • 2023-03-20
相关资源
最近更新 更多