将 Maven 项目导入 Eclipse [英] Importing Maven project into Eclipse

查看:41
本文介绍了将 Maven 项目导入 Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将现有的 Maven 项目导入 Eclipse.我找到了两种方法:

I want to import existing Maven project into Eclipse. I found 2 ways to do it:

  1. 通过命令行运行 mvn eclipse:eclipse
  2. 从 Eclipse 安装 Maven Eclipse 插件.

两者之间有什么区别,哪个更可取?

What is the difference between the both and which one is preferable?

如果我通过Eclipse菜单Help -> Install New Software安装Maven Eclipse插件,我是否还需要修改我的pom.xml以包含Maven Eclipse插件在插件部分?

If I install Maven Eclipse plugin through the Eclipse menu Help -> Install New Software, do I still need to modify my pom.xml to include the Maven Eclipse plugin in the plugins section?

推荐答案

我想将现有的 maven 项目导入到 eclipse 中.我找到了两种方法,一种是从命令行运行 mvn eclipse:eclipse ,另一种是从 eclipse 安装 maven eclipse 插件.两者有什么区别,哪个更可取?

I want to import existing maven project into eclipse. I found 2 ways to do it, one is through running from command line mvn eclipse:eclipse and another is to install maven eclipse plugin from eclipse. What is the difference between the both and which one is preferable?

maven-eclipse-plugin 是一个 Maven 插件 并且一直 一直存在(Maven 1 可用的第一个插件之一,迁移到 Maven 2 的第一个插件之一).很长一段时间以来,它一直是将现有 Maven 项目与 Eclipse 集成导入的唯一合适方式.实际上,它不提供真正的集成,它只是从 Maven 项目生成 .project.classpath 文件(它还支持 WTP).我在 期间使用过这个插件并且对它非常满意(并且此时对于 Maven 的 Eclipse 插件非常不满意,例如 m2eclipse).

The maven-eclipse-plugin is a Maven plugin and has always been there (one of the first plugin available with Maven 1, one of the first plugin migrated to Maven 2). It has been during a long time the only decent way to integrateimport an existing maven project with Eclipse. Actually, it doesn't provide real integration, it just generates the .project and .classpath files (it has also WTP support) from a Maven project. I've used this plugin during years and was very happy with it (and very unsatisfied at this time by Eclipse plugins for Maven like m2eclipse).

m2eclipse 插件是 Maven Eclipse 插件.它实际上是旨在将 Maven 集成到 Eclipse IDE 中的第一个也是最成熟的项目(情况并非总是如此,大约 2 年前它并不真正可用,请参阅 Mevenide vs. M2Eclipse,Q for Eclipse/IAM).但是,即使我不使用从 Eclipse 或 POM 编辑器或其他花哨的向导创建 Maven 项目之类的东西,我不得不说这个插件现在完全可用,提供非常流畅的集成,具有很好的功能......在其他话说,我终于改用它了 :) 我现在将它推荐给任何用户(高级或初学者).

The m2eclipse plugin is one of the Eclipse plugins for Maven. It's actually the first and most mature of the projects aimed at integrating Maven within the Eclipse IDE (this has not always been the case, it was not really usable ~2 years ago, see the feedback in Mevenide vs. M2Eclipse, Q for Eclipse/IAM). But, even if I do not use things like creating a Maven project from Eclipse or the POM editor or other fancy wizards, I have to say that this plugin is now totally usable, provides very smooth integration, has nice features... In other words, I finally switched to it :) I'd now recommend it to any user (advanced or beginners).

如果我通过eclipse菜单Help -> Install New Software安装maven eclipse插件,我是否还需要修改我的pom.xml以在插件部分包含maven eclipse插件?

If I install maven eclipse plugin through the eclipse menu Help -> Install New Software, do I still need to modify my pom.xml to include the maven eclipse plugin in the plugins section?

这个问题有点令人困惑,但答案是否定的.安装 m2eclipse 插件后,只需右键单击包资源管理器和导入...> Maven 项目,即可将现有的 Maven 项目导入 Eclipse.

This question is a bit confusing but the answer is no. With the m2eclipse plugin installed, just right-click the package explorer and Import... > Maven projects to import an existing maven project into Eclipse.

这篇关于将 Maven 项目导入 Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆