2012-09-11 320 views
9

像下面,我跑mvn packageMaven构建错误失败

[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> 

请帮助我。

+0

我假设你有更多的消息......比如不可下载的依赖关系等。 – khmarbaise

回答

0

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

您确定没有连接问题吗?您的antivirii软件不会阻止您下载文物?是不是在您的本地存储库损坏的条目?

4

尝试删除到文件夹

.m2\repository\org\apache\maven\plugins\maven-jar-plugin 
文件系统上

。您的插件jar可能已损坏。

如果这不起作用,尝试删除我遇到类似的问题,一旦码头服务器的文件夹(同样的原因)

+0

这个在我遇到这个问题时有效。 – brettw

1

。原来是一个Maven 3问题。切换到maven 2.2.1后,我的版本运行良好。

0

对于我们来说,这是Eclipse/Maven自动将JDK自动更改为1.5(从1.8开始)时引起的。手动改回到1.8修复了这个问题。

0

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

0

即使面临这个问题。它将通过删除.m2/repository文件夹并再次构建项目来解决。