Maven执行目标org.apache.maven.plugins:maven-jar-plugin失败。

问题描述 投票:14回答:9

就像下面,我在运行 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
9个回答
6
投票

尝试删除到文件夹

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

您的文件系统上。你的插件jar可能已经损坏了。

如果这样不行,请尝试删除jetty-server文件夹(同样的原因)。


2
投票

我曾经遇到过类似的问题。结果发现是maven 3的问题。换成maven 2.2.1后,我的构建运行良好。


2
投票

甚至还遇到过这个问题。只要删除.m2repository文件夹,再重新构建项目就可以解决。


0
投票

它是 为我工作 对于你的POM文件例子,问题应该在其他地方。

你确定那里没有连接问题吗?你的防病毒软件没有阻止你下载工件?你的本地仓库中是不是有一个条目被破坏了?


0
投票

这是Maven 3.3.1和3.3.3中未解决的问题。https:/issues.apache.orgjirabrowseMNG-5787。我升级到了3.3.9,一切都开始工作了。


0
投票

我最近遇到了这个问题,我只需要删除.m2repository中的文件夹,然后重新运行pom,就可以了。


0
投票

应该是在依赖关系中存在一些问题,而maven无法即时解决,尝试在项目根目录下运行这个命令。

mvn dependency:tree

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


0
投票

1.我建议你把.m2文件夹完全删除。

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

3.Maven安装


-1
投票

对我们来说,这是Eclipse Maven自动将JDK从1.8改到1.5时造成的。 手动改回1.8就解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.