Eclipse 提供一種卓越的插件 m2eclipse,該插件使得 Maven 和 Eclipse 能夠無縫集成。
下面列出 m2eclipse 的一些特點(diǎn):
使用以下任意一個(gè)鏈接來安裝 m2eclipse:
Eclipse | URL |
---|---|
Eclipse 3.5 (Gallileo) | Installing m2eclipse in Eclipse 3.5 (Gallileo) |
Eclipse 3.6 (Helios) | Installing m2eclipse in Eclipse 3.6 (Helios) |
以下的示例可以幫助你有效地利用集成 Eclipse 和 Maven.
現(xiàn)在,你可以在 Eclipse 中看到 Maven 工程。
看一下 consumerBanking 工程的屬性,你可以發(fā)現(xiàn) Eclipse 已經(jīng)將 Maven 所依賴的都添加到了它的構(gòu)建路徑里了。
好了,我們來使用 Eclipse 的編譯功能來構(gòu)建這個(gè) Maven 工程。
Maven 開始構(gòu)建工程,你可以在 Eclispe 的控制臺(tái)看到輸出日志。
[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.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec
Results :
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] -------------------------------------------------------------------
現(xiàn)在,右鍵點(diǎn)擊 App.java. 選擇 Run As 選項(xiàng)。選擇 As Java App.
你將看到如下結(jié)果:
Hello World!
更多建議: