本文共 2379 字,大约阅读时间需要 7 分钟。
Eclipse 提供了一个很好的插件 ,该插件能将 Maven 和 Eclipse 集成在一起。
在最新的 Eclipse 中自带了 Maven,我们打开,Windows->Preferences,如果会出现下面的画面:
下面列出 m2eclipse 的一些特点:
选择 Maven Projects 选项。点击 Next 按钮。
点击 Finish 按钮。
现在,你可以在 Eclipse 中看到 Maven 项目。
看一下 consumerBanking 项目的属性,你可以发现 Eclipse 已经将 Maven 所依赖的都添加到了它的构建路径里了。
好了,我们来使用 Eclipse 的编译功能来构建这个 Maven 项目。
Maven 开始构建项目,你可以在 Eclipse 的控制台看到输出日志。
[INFO] Scanning for projects...[INFO] -------------------------------------------------------------------[INFO] Building consumerBanking[INFO] [INFO] Id: com.companyname.bank:consumerBanking:jar:1.0-SNAPSHOT[INFO] task-segment: [package][INFO] -------------------------------------------------------------------[INFO] [resources:resources][INFO] Using default encoding to copy filtered resources.[INFO] [compiler:compile][INFO] Nothing to compile - all classes are up to date[INFO] [resources:testResources][INFO] Using default encoding to copy filtered resources.[INFO] [compiler:testCompile][INFO] Nothing to compile - all classes are up to date[INFO] [surefire:test][INFO] Surefire report directory: C:\MVN\consumerBanking\target\surefire-reports------------------------------------------------------- T E S T S-------------------------------------------------------Running com.companyname.bank.AppTestTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 secResults :Tests run: 1, Failures: 0, Errors: 0, Skipped: 0[INFO] [jar:jar][INFO] -------------------------------------------------------------------[INFO] BUILD SUCCESSFUL[INFO] -------------------------------------------------------------------[INFO] Total time: 1 second[INFO] Finished at: Thu Jul 12 18:18:24 IST 2012[INFO] Final Memory: 2M/15M[INFO] -------------------------------------------------------------------
现在,右键点击 App.java, 选择 Run As 选项。选择 As Java App
你将看到如下结果:
转载地址:http://eosgf.baihongyu.com/