eclipse 配置 maven 編譯代碼

來源:互聯網
上載者:User

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



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.