【问题标题】:Maven failed to execute goal org.apache.maven.plugins:maven-jar-pluginMaven 未能执行目标 org.apache.maven.plugins:maven-jar-plugin
【发布时间】:2012-09-04 01:31:57
【问题描述】:

如下所示,我在运行mvn package时出错

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.3.1:jar (default-jar) on project hello-world: Execution default-jar of goal org.apache.maven.plugins:maven-jar-plugin:2.3.1:jar failed: Unable to load the mojo 'jar' in the plugin 'org.apache.maven.plugins:maven-jar-plugin:2.3.1'. A required class is missing: org/codehaus/plexus/components/io/resources/PlexusIoResourceCollection
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-jar-plugin:2.3.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/maven/repository/org/apache/maven/plugins/maven-jar-plugin/2.3.1/maven-jar-plugin-2.3.1.jar
[ERROR] urls[1] = file:/C:/maven/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[2] = file:/C:/maven/repository/org/apache/maven/maven-archiver/2.4.1/maven-archiver-2.4.1.jar
[ERROR] urls[3] = file:/C:/maven/repository/org/codehaus/plexus/plexus-archiver/1.0/plexus-archiver-1.0.jar
[ERROR] urls[4] = file:/C:/maven/repository/commons-lang/commons-lang/2.1/commons-lang-2.1.jar
[ERROR] urls[5] = file:/C:/maven/repository/org/codehaus/plexus/plexus-utils/2.0.5/plexus-utils-2.0.5.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------: org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

这是我的 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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>sds.jetty.simple</groupId>
<artifactId>hello-world</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>Jetty HelloWorld</name>

<properties>
    <jettyVersion>8.1.2.v20120308</jettyVersion>
</properties>

<dependencies>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-server</artifactId>
        <version>${jettyVersion}</version>
    </dependency>
</dependencies>

<build>
</build>
</project>

【问题讨论】:

  • 我假设您还有更多消息......比如不可下载的依赖项等。

标签: maven maven-jar-plugin


【解决方案1】:

尝试删除到文件夹

.m2\repository\org\apache\maven\plugins\maven-jar-plugin

在您的文件系统上。您的插件 jar 可能已损坏。

如果这不起作用,请尝试删除 jetty-server 文件夹(同理)

【讨论】:

  • maven 不会自动检查/更新损坏的文件吗?如果使用很多包,手动修改文件很耗时。
【解决方案2】:

我曾经遇到过类似的问题。原来是maven 3问题。切换到 maven 2.2.1 后,我的构建运行良好。

【讨论】:

    【解决方案3】:

    甚至面临这个问题。只需删除 .m2/repository 文件夹并重新构建项目即可解决此问题。

    【讨论】:

    • 这对我有用,它的疯狂解决方案需要时间来重新构建整个 repo。我通过重命名现有的.m2 目录来保留备份存储库
    【解决方案4】:

    您的示例 POM 文件是 working for me,问题应该出在其他地方。

    您确定那里没有连接问题吗?您的防病毒软件不会阻止您下载工件?您的本地存储库中的条目是否已损坏?

    【讨论】:

      【解决方案5】:

      这是 Maven 3.3.1 和 3.3.3 中未解决的问题; https://issues.apache.org/jira/browse/MNG-5787 我升级到 3.3.9 并且开始工作了。

      【讨论】:

        【解决方案6】:

        我最近遇到了这个问题,我只需要从 .m2/repository 中删除文件夹并重新运行 pom。成功了。

        【讨论】:

          【解决方案7】:

          1.我建议你彻底删除.m2文件夹

          2.然后做maven -> 更新项目。

          3.Maven安装

          【讨论】:

            【解决方案8】:

            我在使用 maven 版本 3.6.3 时遇到了同样的错误。就我而言,这不是 Maven 的问题。但是我在 src/resource 文件夹中复制了一个非常大的文件夹(5 GB)。删除垃圾文件夹后,一切正常。

            【讨论】:

              【解决方案9】:

              用 Java 8 而不是 Java 6 编译已经解决了我的问题。

              【讨论】:

                【解决方案10】:

                对我们来说,这是 Eclipse / Maven 自动将我们的 JDK 更改为 1.5(从 1.8)引起的。手动改回 1.8 解决了这个问题。

                【讨论】:

                  【解决方案11】:

                  依赖项中应该存在一些 maven 无法即时解决的问题。 尝试在您的项目根目录上运行此命令。

                  mvn dependency:tree
                  

                  这应该可以解决所有依赖问题并帮助您运行应用程序

                  【讨论】:

                    猜你喜欢
                    • 2018-01-24
                    • 1970-01-01
                    • 2020-01-25
                    • 2014-12-04
                    • 2021-05-27
                    • 2018-01-02
                    • 2013-05-30
                    • 2016-02-27
                    • 2015-11-08
                    相关资源
                    最近更新 更多