Maven 项目转 Eclipse

来源:互联网 发布:excel导入mysql 编辑:程序博客网 时间:2024/05/01 09:08

用maven命令创建项目后,使用mvn eclipse:eclipse转为Eclipse项目后,项目不会由Eclipse中的m2e管理,添加依赖将会失效,此处修改.project和.classpath文件以解决问题。

If you have a Maven based Eclipse project that you generated using mvn eclipse:eclipse, you’ll notice you won’t be able to use M2Eclipse (m2e) with it. If you look at the Eclipse .project file, you’ll see this comment.

NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.

Here’s how you can convert your Maven Eclipse Plugin project to m2e. First add the M2Eclipse builder under the buildSpec tag, and the M2Eclipse nature under the natures tag, both inside the .project file.

...<buildCommand>  <name>org.eclipse.m2e.core.maven2Builder</name></buildCommand>
<div class="line number1 index0 alt2"><code class="xml plain">...</code></div><div class="line number2 index1 alt1"><code class="xml plain"><</code><code class="xml keyword">nature</code><code class="xml plain">>org.eclipse.m2e.core.maven2Nature</</code><code class="xml keyword">nature</code><code class="xml plain">></code></div>

Next step is to replace all the M2_REPO libraries in the .classpath file with the M2Eclipse classpath container.

<classpathentrykind="con"path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>


Refresh your Eclipse project. Right click on the project in Project Explorer View and you should now see the Maven option.

- See more at: http://blog.teamextension.com/m2eclipse-m2e-support-for-maven-eclipse-plugin-projects-497



0 0
原创粉丝点击