-

Eclipse提供了一个优秀的插件m2eclipse,它将Maven和Eclipse无缝集成在一起。

下面列出了一些m2eclipse的特性

安装m2eclipse插件

使用以下链接之一来安装m2eclipse:

网址
Eclipse 3.5(Gallileo)

在Eclipse 3.5(Gallileo)中安装m2eclipse

Eclipse 3.6(Helios)

在Eclipse 3.6(Helios)中安装m2eclipse

以下示例将帮助您充分利用集成Eclipse和maven的优势。

在Eclipse中导入一个maven项目

在Eclipse中导入一个maven项目。 在Eclipse中导入一个maven项目。

现在,您可以在eclipse中看到maven项目。

Eclipse中的maven项目。

现在,看看consumerBanking的项目属性。你可以看到,Eclipse已经将Maven依赖项添加到了java创建路径中。

具有Maven依赖关系的Java创建路径。

现在,它使用eclipse的maven功能来创建这个项目。

Maven将开始建设项目。您可以在Eclipse控制台中看到输出

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building consumerBanking 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ consumerBanking ---
[INFO] Deleting C:MVNconsumerBanking	arget
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ consumerBanking ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:MVNconsumerBankingsrcmain
esources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ consumerBanking ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:MVNconsumerBanking	argetclasses
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ consumerBanking ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:MVNconsumerBankingsrc	est
esources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ consumerBanking ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 1 source file to C:MVNconsumerBanking	arget	est-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ consumerBanking ---
[INFO] Surefire report directory: C:MVNconsumerBanking	argetsurefire-reports


-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.companyname.bank.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.063 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ consumerBanking ---
[INFO] Building jar: C:MVNconsumerBanking	argetconsumerBanking-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.406 s
[INFO] Finished at: 2015-09-27T17:58:06+05:30
[INFO] Final Memory: 14M/247M
[INFO] ------------------------------------------------------------------------
使用run as选项运行maven命令。

现在,右键单击App.java。选择运行方式选项。选择作为Java应用程序。

你会看到结果

Hello World!