2013年1月5日土曜日

使用Nexus配置Maven私有仓库


1. 下载Nexus



2. 启动Nexus

nexus-2.0.6-bundle/nexus-2.0.6/bin/jsw/linux-x86-64/nexus 启动


3. 进入Nexus管理页面
http://localhost:8081/nexus/index.html
默认密码 admin admin123

点击Repositories ,可以看到仓库列表,包括下面几种:
Public Repositories    仓库组
3rd part                     三方库,可以上传jar包到这个仓库
Central                      maven中心仓库
Releases                  自己项目中发布的构建
Snapshots                 trunk 下开发一个项目

这里需要注意把Central 仓库的自动更新设置为True:

更新之后能看到Index:


4. 在settings.xml中使用本地仓库:
~/.m2 下新建settings.xml :
Xml代码  收藏代码
  1. <settings>  
  2.     <profiles>  
  3.         <profile>  
  4.           <id>dev</id>  
  5.           <repositories>  
  6.              <repository>  
  7.             <id>nexus</id>                                    
  8.             <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>                        
  9.             <releases>  
  10.                 <enabled>true</enabled>  
  11.                 </releases>  
  12.             <snapshots>  
  13.              <enabled>true</enabled>  
  14.             </snapshots>  
  15.              </repository>  
  16.           </repositories>  
  17.           
  18.          <pluginRepositories>  
  19.   
  20.                 <pluginRepository>  
  21.   
  22.                     <id>nexus</id>  
  23.   
  24.                     <url>http://127.0.0.1:8081/nexus/content/groups/public</url>  
  25.   
  26.                     <releases>  
  27.   
  28.                         <enabled>true</enabled>  
  29.   
  30.                     </releases>  
  31.   
  32.                     <snapshots>  
  33.   
  34.                         <enabled>true</enabled>  
  35.   
  36.                     </snapshots>  
  37.   
  38.                 </pluginRepository>  
  39.   
  40.             </pluginRepositories>  
  41.   
  42.         </profile>  
  43.     </profiles>  
  44.   
  45.     <activeProfiles>  
  46.         <activeProfile>dev</activeProfile>  
  47.        </activeProfiles>  
  48.   
  49. </settings>  

现在可以通过maven实验一下:
mvn archetype:create  -DgroupId=com.yourcompany -DartifactId=myproject  -DarchetypeArtifactId=maven-archetype-webapp

yunpeng@yunpeng-duitang:~/workspace$ mvn archetype:create  -DgroupId=com.yourcompany -DartifactId=myproject  -DarchetypeArtifactId=maven-archetype-webapp
[INFO] Scanning for projects...
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom (5 KB at 27.2 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom
Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom (13 KB at 409.6 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/maven-parent/16/maven-parent-16.pom
Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/maven-parent/16/maven-parent-16.pom (23 KB at 463.8 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/apache/7/apache-7.pom
Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/apache/7/apache-7.pom (15 KB at 563.7 KB/sec)
Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar
Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar (23 KB at 459.9 KB/sec)

参考:
http://blog.csdn.net/arvinzhuo/article/details/4244061
http://kidsmopi.iteye.com/blog/232554

0 件のコメント:

コメントを投稿