eclipse 配置 maven 編譯程式碼
1. 首先安裝maven外掛,進入eclipse的help->marketplace,在find框中輸入“maven”,選擇“maven integration for eclipse(juno and newer)”項的install按鈕
2. 進入window->preferences視窗,選擇java->Installed JREs,預設情況下只有eclipse一項,這裡要通過add按鈕增加jdk對對應的路徑加進來,否則在編譯的時候會報錯:
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
接著,進入Installed JREs的子項Execute Environment:在左側選擇JavaSE-1.6,右側選擇jdk
3. 在專案檔案上單擊右鍵,選擇Maven->update project。
如果這個專案不是maven專案,則單擊專案圖示,現在configure->Convert to Maven project
4. 右鍵,選擇Run As->Maven install,之後會開始下載編譯過程中所需的檔案
5. 之後,選擇Maven Build,第一次執行會出現Run Configurations對話方塊,主要是在Goals框中輸入要編譯出的目標檔案,Goals的選項包括:
validate
initialize
generate-sources
process-sources
generate-resources
process-resources
compile compile
process-classes
generate-test-sources
process-test-sources
generate-test-resources
process-test-resources
test-compile
process-test-classes
test
prepare-package
package
pre-integration-test
integration-test
post-integration-test
verify
install
deploy
如果goals不輸入內容,編譯的時候會提示
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format.....
進一步的細節可以參考 http://gavin-chen.iteye.com/blog/336607