重裝了遍系統(tǒng),今天使用Eclipse創(chuàng)建maven web項目的時候一直麻煩不斷,先是創(chuàng)建項目的時候提示
No plugin found for prefix 'archetype' in the current project
的錯誤信息。搞了半天沒解決,最后在StackOverflow查了一下發(fā)現(xiàn)因為我開著代理的原因。崩潰。
好不容易創(chuàng)建好項目了,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)
在網(wǎng)上查閱了好多解決方案,現(xiàn)在總結(jié)出兩種比較靠譜的:
- 直接在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目錄下沒有l(wèi)ifecycle-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...。