对Linux及Maven都不熟悉,在网上折腾,然后总结如下:
一.搭建仓库(JDK required):
linux platform, IP:192.168.2.99
1.download apache-maven-x.x.x-bin.tar.gz
2.download nexus-oss-webapp-x.x.x.x-bundle.tar.gz
3.
tar -zxvf apache-maven-x.x.x-bin.tar.gz -C /usr/java/
4.add enviroment variable:
a. vi /etc/profile;
b. append 'MAVEN_HOME=/usr/java/***'
c. append 'PATH=${PATH}:${MAVEN_HOME}/bin'
d. append 'export MAVEN_HOME PATH'
e. source /etc/profile
5.tar -zxvf nexus-oss-webapp-x.x.x.x-bundle.tar.gz -C /usr/java/
6.startup(shutdown) nexus:
a. cd nexus/nexus-oss-webapp-1.9.0.2/bin/jsw/linux-x86-32/
b.
./nexus start(stop)
7.test:
http://localhost:8081/nexus
ok, login as
admin/admin123 (default)
二、使用Mavan仓库:
windows platform, IP:192.168.2.3
1.download and setup apache-maven-x.x.x-bin.zip (D:/maven)
2.add enviroment variable:
new MAVEN_HOME:D:/maven
add to path:%MAVEN_HOME%/bin
test:mvn -version, ok
3.open the file "
settings.xml " under the folder "d:/maven/conf"
add the next chars into the file:
C:/.m2/repository
nexus-releases
admin
admin
nexus-snapshots
admin
admin
*
linux-nexus
http://192.168.2.99:8081/nexus/content/groups/public
nexus
dev
nexus
http://192.168.2.99:8081/nexus/content/groups/public/
true
true
nexus
http://192.168.2.99:8081/nexus/content/groups/public
true
true
save, ok.
4.mkdir "d:/workspace"
5.
mvn archetype:generate
6.choose the default selection(16)
7.input some informations(the project name:helloworld)
8.ok, look the dir "D:/workspace", there is a folder "helloworld"
9.open the file "
pom.xml " under "helloworld", add some dependencies, example:
org.springframework
2.5.6.SEC02
jar
compile
org.apache.struts
2.2.1
jar
compile
javax.servlet
2.5
jar
compile
10.run the command "
mvn install " under "helloword", then, it will download some jars and poms
into "C:/.m2/repository"(default) from 192.168.2.99.
11.convert this maven project to eclipse project:
under the folder "helloworld", run "
mvn eclipse:eclipse ".
说明:192.168.2.99是虚拟机中Linux的IP,192.168.2.3是虚拟机中Win7的IP。