Maven 项目转 Eclipse

本文详细介绍了如何将使用maven-eclipse-plugin创建的Maven项目转换为可以被M2Eclipse管理的Eclipse项目,通过修改.project和.classpath文件来解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值