重装了遍系统,今天使用Eclipse创建maven web项目的时候一直麻烦不断,先是创建项目的时候提示
No plugin found for prefix 'archetype' in the current project
的错误信息。搞了半天没解决,最后在StackOverflow查了一下发现因为我开着代理的原因。崩溃。
好不容易创建好项目了,pom.xml配置文件一直在第二行提示错误
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:
2.5.1:testCompile (execution: default-testCompile, phase: test-compile)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:
2.5.1:compile (execution: default-compile, phase: compile)
在网上查阅了好多解决方案,现在总结出两种比较靠谱的:
- 直接在pom.xml文件中加入如下配置:
<build>
<pluginManagement>
<plugins>
<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-compiler-plugin</artifactId>
<versionRange>[2.5,)</versionRange>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
记得保存之后在项目上右击Maven -> Update Project...
- 菜单栏 Window -> Preferences -> Maven -> Lifecycle Mapping
查看Change mapping file location一栏的地址,一般都是xxxxx/.metadata/.plugins/org.eclipse.m2e.core/lifecycle-mapping-metadata.xml,然而我的org.eclipse.m2e.core目录下没有lifecycle-mapping-metadata.xml文件,于是我们需要到Eclipse的安装目录下找到plugins\org.eclipse.m2e.lifecyclemapping.defaults_xxxxx.jar文件,解压之后就会看到一个lifecycle-mapping-metadata.xml文件,打开编辑他,在
</pluginExecutions>
标签中加入如下配置
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<versionRange>[2.5,)</versionRange>
<goals>
<goal>testCompile</goal>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
保存之后将其复制到上面说的xxxxx/.metadata/.plugins/org.eclipse.m2e.core/lifecycle-mapping-metadata.xml目录。
可以把Preferences -> Maven中的Update Maven projects on startup选项勾上,然后重启Eclipse即可。
如果仍有错就手动在项目上右击Maven -> Update Project...。
网友评论