maven+nexus环境搭建

使用maven管理项目能轻松管理项目的jar,实现项目的编译,单元测试,打包和发布。

nexus环境的搭建网上很多。

java环境设置:

  变量名:JAVA_HOME
  变量值:C:\Program Files\Java\jdk1.7.0
  变量名:CLASSPATH
  变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;

  变量名:Path
  变量值:%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;

maven环境搭建:

  maven_home=D:\apache-maven-2.2.1
  PATH=%maven_home%\bin

maven设置:

  在maven_home\conf\setting.xml中修改以下节点

<!--修改本地jar文件存放地址-->
<
localRepository>E:/m2/repository</localRepository> <servers> <server> <id>nexus-snapshots</id> <username>username</username> <password>password</password> </server> </servers> <mirrors> <mirror> <id>nexus</id> <mirrorOf>*</mirrorOf> <name>internal nexus repository</name> <url>http://192.168.1.33:8081/nexus/content/groups/public/</url> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <repositories> <repository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile> <profile> <id>maven-central</id> <repositories> <repository> <id>central</id> <url>http://repo1.maven.org/maven2/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://repo1.maven.org/maven2/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles>

 

maven创建新项目:

  创建普通java项目:mvn archetype:create -DgroupId=com.xxx -DartifactId=XXXTest

  创建web项目:mvn archetype:create -DgroupId=com.xxx  -DartifactId=XXXTest  -DarchetypeArtifactId=maven-archetype-webapp

  创建eclipse web项目:mvn -Dwtpversion=1.0 eclipse:eclipse 

eclipse中maven配置:

  eclipse安装maven插件后,进入Window->Preferences->Maven->User Settings设置成maven_home\conf\setting.xml文件即可

posted @ 2012-11-29 09:25  一直很低调....  阅读(399)  评论(0编辑  收藏  举报