27 12月 2006

Eclipse and Maven ide(1)

在Eclipse上使用Maven2 一、利用Maven ide來管理 Eclipse Project中使用到的Library 執行
mvn -Declipse.workspace= eclipse:add-maven-repo
如此一來,會在Eclipse中加入一個名為“M2_REPO“的變數,方便讓使用者指向在.m2/repository中的jar檔。 二、利用Maven2來產生Eclipse的Project,可以再區分為單一Module的Single Project或是多個Module的Multiple Project (1)Single Project 先產生pom.xml
mvn archetype:create -DgroupId=yourgroup -DartifactId=single
此時會產生一個名為single的目錄,並產生pom.xml及基本的src架構 再執行
mvn eclipse:eclipse
就會產生Eclipse所需要的.project及.classpath (2)Multiple Project 產生parent(root) project
mvn archetype:create -DgroupId=yourgroup -DartifactId=multiple
刪除multiple folder下的src目錄
rm -r src
並將pom.xml中的packaging由jar改為pom 再於multiple folder下執行
mvn archetype:create -DgroupId=yourgroup -DartifactId=multiple-core mvn archetype:create -DgroupId=yourgroup -DartifactId=multiple-module
產生兩個sub project,並修改multiple-module的pom.xml,加入一個指向core的dependency
yourgroup multiple-core 1.0-SNAPSHOT
最後在multiple目錄下執行
mvn install mvn eclipse:eclipse
即會在multiple,multiple-core,multiple-module中產生Eclipse所需要的檔案,要使用的話只要在Eclipse中import multiple project,就會連帶將multiple-core,multiple-module等一併加入Eclipse中。

1 則留言:

匿名 提到...

I do not know if it's just me or if everybody else encountering issues with
your site. It appears as if some of the written text in your content are running
off the screen. Can someone else please provide feedback and let
me know if this is happening to them as well? This could be a issue
with my browser because I've had this happen previously.
Appreciate it

Feel free to surf to my site: plan nike