和下面一样,我在运行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>
尝试删除到文件夹
.m2repositoryorgapachemavenpluginsmaven-jar-plugin
在您的文件系统上。您的插件jar可能已损坏。
如果这不起作用,请尝试删除jetty服务器文件夹(原因相同)
我曾经遇到过类似的问题。事实证明,这是一个专家3的问题。在切换到maven 2.2.1之后,我的构建运行良好。
甚至面临这个问题。只需删除.m2/存储库文件夹并重新构建项目即可解决此问题。
用Java 8而不是Java 6编译已经解决了我的问题。
对于您的示例POM文件,它对我有效,问题应该在其他地方。
你确定那里没有连接问题吗?你的antivirii软件不会阻止你下载文物吗?本地存储库中的条目是否已损坏?
对我们来说,这是因为Eclipse/Maven自动将JDK从1.8更改为1.5。手动更改回1.8解决了这个问题。
这是Maven 3.3.1和3.3.3中未解决的问题;https://issues.apache.org/jira/browse/MNG-5787我升级到了3.3.9,一切都开始工作了。
我最近遇到了这个问题,我只需要从.m2/存储库中删除文件夹并重新运行pom。它奏效了。
1.我建议您完全删除.m2文件夹
2.然后执行maven->更新项目。
3.Maven安装
我在使用maven 3.6.3版本时也遇到了同样的错误。就我而言,这与maven无关。但是我在src/resource文件夹中复制了一个非常大的文件夹(5GB)。删除垃圾文件夹后,一切正常。
依赖关系中应该存在一些maven无法即时解决的问题。请尝试在项目根目录上运行此命令。
mvn dependency:tree
这应该可以解决所有的依赖性问题,并帮助您运行应用程序