Maven-无法使用Java 10执行目标org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile

时间:2018-09-16 01:39:48

标签: java maven heroku build compiler-errors

im试图使用Git bash将不和谐的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

我认为我需要在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>

我需要添加什么到我的pom.xml中?

5 个答案:

答案 0 :(得分:1)

仅从Java9(https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html)开始才支持-release参数。确保您的maven安装至少使用Java9。

答案 1 :(得分:0)

尝试使用版本3.8.0而不是版本3.7.0。还要确保将JAVA_HOME设置为Java 8安装。参见this link

答案 2 :(得分:0)

确保您的存储库根目录中有system.properties文件,内容如下:

java.runtime.version=10

有关更多信息,请参见Heroku documentation on Java versions

答案 3 :(得分:0)

There's another option instead of adding the properties file in the repo location.

You can add this code in POM.xml:

<properties>
    <java.version>1.8.0_171</java.version>
</properties>

答案 4 :(得分:0)

从pom.xml中删除<release>10</release>,并在内容为system.properties的资源中添加java.runtime.version=10。它应该与jdk 10一起使用。或者您可以根据需要更改JDK。