无法使用Maven构建项目 – 兼容性错误

huangapple go评论74阅读模式
英文:

cant build project using maven - compability error

问题

我正在尝试重新运行一些旧项目,作为一个入门,我想构建这里的示例代码:[github.com/skadistats/clarity-examples][1]
你可以在这里找到 .pom 文件:[这里][2]

尝试构建时出现以下错误:

[INFO] -----------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] -----------------------------------------------------------------------
[INFO] Total time: 1.647 s
[INFO] Finished at: 2020-04-09T14:43:24+02:00
[INFO] -----------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.6:jar
  (default-jar) on project clarity-examples: Execution default-jar of goal org.ap
ache.maven.plugins:maven-jar-plugin:2.6:jar failed: An API incompatibility was e
ncountered while executing org.apache.maven.plugins:maven-jar-plugin:2.6:jar: ja
va.lang.ExceptionInInitializerError: null
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-jar-plugin:2.6
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy

我一直在尝试按照[这个旧帖子][1]中的建议进行操作,但未能解决问题。

C:\>mvn -version
C:\
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: c:\Users\MyName\Downloads\clarity\apache-maven-3.6.3\bin\..
Java version: 14, vendor: Oracle Corporation, runtime: C:\Progra~1\Java\jdk-14
Default locale: en_US,platform encoding: Cp1252
OS name: "windows 8.1",version: "6.3",arch: "amd64",family: "windows"

不确定我的 JAVA_HOME 是否设置正确,确实可以通过回显来验证
[环境变量][3]

  [1]: https://stackoverflow.com/questions/20218486/unable-to-build-using-maven-with-error-failed-to-execute-goal-org-apache-maven
  [2]: https://github.com/skadistats/clarity-examples/blob/master/pom.xml
  [3]: https://i.stack.imgur.com/Gib6j.png


<details>
<summary>英文:</summary>

Im trying to get a few old projects running again and as a starter I would like to build the example codes here: [github.com/skadistats/clarity-examples][1] 
You can find the .pom [here][2]

trying to build this spits out the following error:

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  1.647 s
    [INFO] Finished at: 2020-04-09T14:43:24+02:00
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.6:jar
     (default-jar) on project clarity-examples: Execution default-jar of goal org.ap
    ache.maven.plugins:maven-jar-plugin:2.6:jar failed: An API incompatibility was e
    ncountered while executing org.apache.maven.plugins:maven-jar-plugin:2.6:jar: ja
    va.lang.ExceptionInInitializerError: null
    [ERROR] -----------------------------------------------------
    [ERROR] realm =    plugin&gt;org.apache.maven.plugins:maven-jar-plugin:2.6
    [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy

Ive been trying to follow the advice given [in this old thread][1], but couldnt resolve the issue.

    C:\&gt;mvn -version
    C:\
    Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
    Maven home: c:\Users\MyName\Downloads\clarity\apache-maven-3.6.3\bin\..
    Java version: 14, vendor: Oracle Corporation, runtime: C:\Progra~1\Java\jdk-14
    Default locale: en_US, platform encoding: Cp1252
    OS name: &quot;windows 8.1&quot;, version: &quot;6.3&quot;, arch: &quot;amd64&quot;, family: &quot;windows&quot;


unsure if my JAVA_HOME is set correctly, echoing it certainly works
[environmental variable][3]


  [1]: https://stackoverflow.com/questions/20218486/unable-to-build-using-maven-with-error-failed-to-execute-goal-org-apache-maven
  [2]: https://github.com/skadistats/clarity-examples/blob/master/pom.xml
  [3]: https://i.stack.imgur.com/Gib6j.png

</details>


# 答案1
**得分**: 0

我能够重现这个问题:在Java版本13及以下版本中可以正常工作,在版本14中,maven-jar-plugin的版本2.6会产生该错误。
您可以选择使用Java 13,或者更改pom文件:将第72行的maven-jar-plugin版本2.6更改为3.2.0。

<details>
<summary>英文:</summary>

I can reproduce this: with Java up to version 13 it works, in version 14 the maven-jar-plugin version 2.6 gives that error.
You can either use Java 13, or change the pom: at line 72 put 3.2.0 instead of 2.6 for the versione of the maven-jar-plugin

</details>



huangapple
  • 本文由 发表于 2020年4月9日 21:05:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/61121858.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定