簡體   English   中英

Maven-無法使用Java 10執行目標org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile

[英]Maven - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile Using java 10

我正在嘗試使用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中?

僅從Java9開始才支持-release參數( https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html )。 確保您的maven安裝至少使用Java9。

確保存儲庫的根目錄中具有system.properties文件,其中包含以下內容:

java.runtime.version=10

有關更多信息,請參見有關Java版本Heroku文檔。

嘗試使用版本3.8.0而不是版本3.7.0。 還要確保將JAVA_HOME設置為Java 8安裝。 看到這個鏈接

除了在回購位置添加屬性文件外,還有另一種選擇。

您可以在POM.xml中添加以下代碼:

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

從pom.xml中刪除<release>10</release> ,並在內容為java.runtime.version=10資源中添加system.properties 它應該與jdk 10一起使用。或者,您可以根據需要更改JDK。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM