clipse加载maven工程提示pom.xml无法解析org.apache.maven.plugins:maven-resources-plugin:

在别的机子上创建一个maven工程,复制到本机上导入,出现pom.xml文件错误,提示错误如下:

报错信息代码
  1. Multipleannotationsfoundatthisline:
  2. -Executiondefault-testResourcesofgoalorg.apache.maven.plugins:maven-resources-plugin:2.4.3:testResourcesfailed:
  3. Pluginorg.apache.maven.plugins:maven-resources-plugin:2.4.3oroneofitsdependenciescouldnotberesolved:Failedtocollect
  4. dependenciesfororg.apache.maven.plugins:maven-resources-plugin:jar:2.4.3()(org.apache.maven.plugins:maven-resources-
  5. plugin:2.4.3:testResources:default-testResources:process-test-resources)
  6. -Pluginexecutionnotcoveredbylifecycleconfiguration:org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
  7. (execution:default-compile,phase:compile)
  8. -CoreException:CouldnotgetthevalueforparametercompilerIdforpluginexecutiondefault-compile:
  9. PluginResolutionException:Pluginorg.apache.maven.plugins:maven-compiler-plugin:2.3.2oroneofitsdependenciescouldnotbe
  10. resolved:Failedtocollectdependenciesfororg.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2():
  11. ArtifactDescriptorException:Failedtoreadartifactdescriptorfororg.apache.maven:maven-plugin-api:jar:2.0.6:
  12. ArtifactResolutionException:Failuretotransferorg.apache.maven:maven-plugin-api:pom:2.0.6fromhttp://repo1.maven.org/
  13. maven2wascachedinthelocalrepository,resolutionwillnotbereattempteduntiltheupdateintervalofcentralhaselapsedor
  14. updatesareforced.Originalerror:Couldnottransferartifactorg.apache.maven:maven-plugin-api:pom:2.0.6from/tocentral(http://
  15. repo1.maven.org/maven2):nulltohttp://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-
  16. api-2.0.6.pom
  17. -CoreException:CouldnotgetthevalueforparametercompilerIdforpluginexecutiondefault-testCompile:
  18. PluginResolutionException:Pluginorg.apache.maven.plugins:maven-compiler-plugin:2.3.2oroneofitsdependenciescouldnotbe
  19. resolved:Failedtocollectdependenciesfororg.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2():
  20. ArtifactDescriptorException:Failedtoreadartifactdescriptorfororg.apache.maven:maven-plugin-api:jar:2.0.6:
  21. ArtifactResolutionException:Failuretotransferorg.apache.maven:maven-plugin-api:pom:2.0.6fromhttp://repo1.maven.org/
  22. maven2wascachedinthelocalrepository,resolutionwillnotbereattempteduntiltheupdateintervalofcentralhaselapsedor
  23. updatesareforced.Originalerror:Couldnottransferartifactorg.apache.maven:maven-plugin-api:pom:2.0.6from/tocentral(http://
  24. repo1.maven.org/maven2):nulltohttp://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-
  25. api-2.0.6.pom
  26. -Executiondefault-resourcesofgoalorg.apache.maven.plugins:maven-resources-plugin:2.4.3:resourcesfailed:Plugin
  27. org.apache.maven.plugins:maven-resources-plugin:2.4.3oroneofitsdependenciescouldnotberesolved:Failedtocollect
  28. dependenciesfororg.apache.maven.plugins:maven-resources-plugin:jar:2.4.3()(org.apache.maven.plugins:maven-resources-
  29. plugin:2.4.3:resources:default-resources:process-resources)
  30. -Pluginexecutionnotcoveredbylifecycleconfiguration:org.apache.maven.plugins:maven-compiler-plugin:
  31. 2.3.2:testCompile(execution:default-testCompile,phase:test-compile)

错误信息出现在pom头的project标签,project标签内容是:

Xml代码
  1. <projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd">

原:

这是由于缺少maven-resources-plugin-2.4.3.jar文件。这个文件是在{user.home}\.m2 \repository\org\apache\maven\plugins\maven-resources-plugin\下。 {user.home}是maven的配置路径,一般是我的文档,是window-preferences-MyEclipse- Maven4MyEclipse-User Setting里面的Local Repository。

解决方案

1、在pom.xml文件中加入maven-resources-plugin配置

Xml代码
  1. <dependency>
  2. <groupId>org.apache.maven.plugins</groupId>
  3. <artifactId>maven-resources-plugin</artifactId>
  4. <version>2.4.3</version>
  5. </dependency>


2、在命令行下运行mvn install ,如果执行正确应该会在{user.home}\.m2\repository\org\apache\maven\plugins\maven- resources-plugin\下看到maven-resources-plugin-2.4.3.jar文件
3、刷新工程(右键工程选择刷新项)

4、刷新maven配置,右键工程节点,选择Maven4MyEclipse-Update Project Configuration

你可能感兴趣的:(resource)