错误类型:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.7:run (execution: define-classpath, phase: process-resources)
错误原因:
eclipse的m2e插件还没有支持到execution
网上找到的比较详细的错误解释:
To solve some long-standing issues, m2e 1.0 requires explicit instructions what to do with all Maven plugins bound to "interesting" phases (see M2E interesting lifecycle phases) of project build lifecycle. We call these instructions "project build lifecycle mapping" or simply "lifecycle mapping" because they define how m2e maps information from project pom.xml file to Eclipse workspace project configuration and behaviour during Eclipse workspace build.
Project build lifecycle mapping configuration can be specified in project pom.xml, contributed by Eclipse plugins and there is also default configuration for some commonly used Maven plugins shipped with m2e. We call these "lifecycle mapping metadata sources". m2e will create error marker like below for all plugin executions that do not have lifecycle mapping in any of the mapping metadata sources.
Plugin execution not covered by lifecycle configuration:
org.apache.maven.plugins:maven-antrun-plugin:1.3:run(execution: generate-sources-input, phase: generate-sources)
m2e matches plugin executions to actions using combination of plugin groupId, artifactId, version range and goal. There are three basic actions that m2e can be instructed to do with a plugin execution --ignore, execute and delegate to a project configurator.
解决方案:
修改pom文件:
添加如下:
<build>
<pluginManagement>
<plugins>
<!-- add by M-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<goals>
<goal>run</goal>
</goals>
<versionRange>[1.7,)</versionRange>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<!-- end ending -->
注意在错误中,
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.7:run (execution: define-classpath, phase: process-resources)上述所填内容中,groupId就是configuration冒号后面的内容,artifactId为再冒号后面的内容;版本号versionRange为后面的版本号,goal为版本号后面的run
如果该错误是出现在pom文件中的parent标签,则要在parent项目的pom文件中添加该内容,如果是出现在本pom文件的excution处,则是在该pom文件出错的plugins标签内添加该内容。
最后要记得在修改完之后,点击项目的右键---Maven---Update Project
pluginManagement标签的作用是作为公用的插件配置项,给子项目共用的。
好吧,问题算是合理地解决了。可也有人说这个配置不该放在pom文件里,应该是ide来处理这个配置,就有了这个:http://liwenqiu.me/blog/2012/12/19/maven-lifecycle-mapping-not-converted/ 在eclipse->preference->maven->lifecycle mappings中,myeclipse的话Maven4MyEclipse->Lifecycle mappings,想上面所示进行配置,保存更新project。eclipse默认配置路径是没有lifecycle-mapping-metadata.xml这个文件的,只有<项目名>.lifecyclemapping一系列这样的文件,但提供一个按钮“Open workspace lifecycle mappings metadata”里进行编辑。或者Change mapping file location。 好吧,这样也许是最应该的处理的方式,但让每个开发人员都改下ide配置,还不如直接改下pom.xml文件的配置,最终采用了修改pom.xml文件的方式。 基于maven的项目,使用各种maven plugin来完成开发中的各种工作,例如编译代码,打包,部署等等… 每个plugin包含许多的goal,用来做特定的事情。典型的基于java的maven项目就有 clean compile test package deploy等goal要执行。除了这些比较常见的goal之外,项目中还可以使用大量的第三方的plugin,甚至自己动手开发的plugin。
随之而来的问题是,在eclipse中编辑maven项目的时候,eclipse并不知道这些goal要做什么,通用的goal还好说,特殊用途的goal就没有办法了。所以m2eclipse这个集成maven到eclipse的plugin就提供了开发extra的能力,eclipse利用这些extra来完成本来在maven plugin要干的活。
如果eclipse没有办法知道某个goal要干什么,那么通常就会看到如下的错误信息:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-dependency-plugin:2.6:copy (execution: default, phase: validate) 由于我个人更倾向于在命令行下让maven干活,而eclipse更多的只是充当编辑器的角色,所以我要的只是让eclipse忽略掉这些goal就好了。
参考这里https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html之后,要做的就是告诉eclipse要忽略的goal.
参考:
http://blog.csdn.net/xxd851116/article/details/25197373
http://blog.sina.com.cn/s/blog_725eee7e01015axt.html