編譯mahout源碼並導到eclipse中

來源:互聯網
上載者:User

為什麼要編譯源碼呢?其實直接用二進位包更省事,只是為了方便讀取源碼和修改源碼
1.直接在mahout安裝目錄下使用mvn install,這樣mahout目錄下的所有檔案就都編譯並打包安裝,可以在各模組下的target目錄中看到class目錄和產生的jar包
2.如果只想編譯部分,例如編譯core:更換到core目錄下,mvn compile,此時沒有產生jar包,只產生了.class檔案,之後可以mvn package在目前的目錄下產生jar包,然後在mvn install在本地Repository中安裝jar
3.執行mvn clean後,會將target目錄刪掉,本地Repository中保留了相應的jar包
4.此時編譯後的mahout,還是不能直接導到eclipse工程中,下載m2eclipse外掛程式,然後建立maven project,然後在pom.xml中選擇Repository中的jar包導進來

如何將mahout源碼導到eclipse中

方法一:
1.安裝m2eclipse外掛程式,http://m2eclipse.sonatype.org/installing-m2eclipse.html,按照提示,一步步線上下載和安裝外掛程式,當然也可以直接到m2eclipse官網上下載外掛程式,然後放到eclispe的安裝目錄下的plugins目錄中,然後file->import->Maven->Existing Maven Projects,然後選擇要匯入的模組,編譯完後,可以看到此時mahout安裝目錄下的各模組目錄的target目錄下多了classes目錄,即.java源檔案編譯產生後的.class

方法二:

此種方法不需要安裝m2eclipse外掛程式

1.在mahout安裝目錄下,用mvn eclipse:eclipse,此時已產生eclipse的關聯檔案

2.如果mahout沒經過編譯,即本地Repository沒有相關mahout的jar包的話,在mahout源碼目錄下,先使用mvn -Declipse.workspace= eclipse:add-maven-repo,如果Repository有相關jar包了,這一步省掉

3.開啟eclipse,匯入mahout中的各個項目,發現報錯,提示少M2_REPO變數,然後在eclipse中Open Window > Preferences > Java > Build Path > Classpath Valirables ->“New” and Add Name as “M2_REPO” and Path as Maven 2 repository path ,詳見參考資料

本人在windows環境下使用的第一種方法編譯的mahout源碼,使用第二種方法在ubuntu環境下編譯的mahout源碼 

 

參考資料:

1.http://hi.baidu.com/pakko/blog/item/a957f4c23af3c50e0ff477a1.html
2.http://shuyo.wordpress.com/2011/02/01/mahout-development-environment-with-maven-and-eclipse-1/3.http://maven.apache.org/guides/mini/guide-ide-eclipse.html4.http://www.cnblogs.com/phoebus0501/archive/2011/05/10/2042511.html5.https://cwiki.apache.org/confluence/display/MAHOUT/BuildingMahout

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.