Maven - 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile Using java 10
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52350260/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile Using java 10
提问by Cr?ss Marian
im trying to upload my discord bot project to Heroku using Git bash My project is java 10 and im using Maven but i get this error :
我正在尝试使用 Git bash 将我的 discord bot 项目上传到 Heroku 我的项目是 java 10,我使用的是 Maven,但出现此错误:
remote: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project bot_discord: Fatal error compiling: invalid flag: --release -> [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/MojoExecutionException
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
i think i need to add something to my Pom.xml but i dont understand what to add ! my pom.xml :
我想我需要向我的 Pom.xml 添加一些东西,但我不明白要添加什么!我的 pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kino.bot</groupId>
<artifactId>bot_discord</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Bot Ryo</name>
<description>Mon bot</description>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<release>10</release>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>3.7.1_422</version>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
</dependencies>
</project>
what do i need to add to my pom.xml ?
我需要在 pom.xml 中添加什么?
采纳答案by codefinger
Ensure that you have system.properties
file in the root directory of your repository with the following contents:
确保system.properties
您的存储库的根目录中有包含以下内容的文件:
java.runtime.version=10
For more info see the Heroku documentation on Java versions
有关更多信息,请参阅有关 Java 版本的Heroku 文档
回答by tom
回答by tom
The -release argument is supported only since Java9 (https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html). Make sure your maven installation is using at least Java9.
-release 参数仅从 Java9 ( https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html) 开始支持。确保您的 maven 安装至少使用 Java9。
回答by HARSH KHATRI
There's another option instead of adding the properties file in the repo location.
还有另一种选择,而不是在 repo 位置添加属性文件。
You can add this code in POM.xml:
您可以在 POM.xml 中添加以下代码:
<properties>
<java.version>1.8.0_171</java.version>
</properties>
回答by Abhishek
Remove <release>10</release>
from pom.xml and add system.properties
in resources with content java.runtime.version=10
. It should work with jdk 10. Or you can change the JDK as per your need.
<release>10</release>
从 pom.xml 中删除并添加system.properties
具有 content 的资源java.runtime.version=10
。它应该适用于 jdk 10。或者您可以根据需要更改 JDK。