Nexus私服搭建_01

Nexus私服安装

 

第一步:下载nexus-webapp-2.9.0war包,然后拷贝到tomcat下的webapps目录中

第二步:启动tomcat

第三步:访问http://localhost:8080/nexus/显示如下:

 Nexus私服搭建_01

 

第四步:点击右上角“log in” ,输入username:admin 和Password:admin123登录

 

 Nexus私服搭建_01


第五步:登录成功


Nexus私服搭建_01

 

 

第六步:点击Views/Repositories 中Repositories

 

 Nexus私服搭建_01

Nexus内置仓库说明:

(1)Maven Central:该仓库代理Maven*仓库,其策略为Release,因此只会下载和缓存*仓库中的发布版本构件。

(2)Releases:这是一种策略为Release的宿主类型仓库,用来部署组织内部的发布版本构件。

(3)Snapshots:这是一个策略为Snapshot的宿主类型仓库,用来部署组织内部的快照版本构件。

(4)3rd party:这是一个策略为Release的宿主类型仓库,用来部署无法从公共仓库获得的第三方发布版本构件。

(5)Public Repositories:该仓库组将上述所有策略为Release的仓库聚合并通过一致的地址提供服务。

第七步:创建宿主目录和代理仓库

· Hosted:本地仓库,通常我们会部署自己的构件到这一类型的仓库。 

o 包括3rd party仓库,Releases仓库,Snapshots仓库

· Proxy:代理仓库,它们被用来代理远程的公共仓库,如maven*仓库。 

· Group:仓库组,用来合并多个hosted/proxy仓库,通常我们配置maven依赖仓库组。 

第八步:创建仓库组

点击Public Repositories仓库,在Configurations栏中选取需要合并的仓库,点击箭头加到左边保存即可

 

 Nexus私服搭建_01

第九步:下载Index索引并进行构建搜索(GAV搜索)

配置文件和顺序:MAVEN_HOME/conf/setting.xml-à~/.m2/setting.xml-àproject

第十步:配置所有构件均从私服下载,在~/.m2/setting.xml中配置如下:

[html] view plain copy
 print?Nexus私服搭建_01Nexus私服搭建_01
  1. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"  
  2.           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  3.           xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">  
  4.   <mirrors>  
  5.     <mirror>  
  6.     <!--此处配置所有的构建均从私有仓库中下载 *代表所有,也可以写central -->  
  7.       <id>nexus</id>  
  8.       <mirrorOf>*</mirrorOf>  
  9.       <name>central Repo</name>  
  10.       <url>http://localhost:8089/nexus-2.9.0/content/groups/public/</url>  
  11.     </mirror>  
  12.   </mirrors>  
  13.   
  14.   <profiles>  
  15.     <profile>  
  16.         <id>nexus</id>  
  17.         <repositories>  
  18.             <repository>  
  19.                 <id>central</id>  
  20.                 <name>Central</name>  
  21.                 <url>http://repo2.maven.org/maven2</url>  
  22.                 <releases><enabled>true</enabled></releases>  
  23.                 <snapshots><enabled>true</enabled></snapshots>  
  24.             </repository>  
  25.         </repositories>  
  26.   
  27.         <pluginRepositories>  
  28.             <pluginRepository>  
  29.                 <id>central</id>  
  30.                 <url>http://repo2.maven.org/maven2</url>  
  31.                 <releases><enabled>true</enabled></releases>  
  32.                 <snapshots><enabled>true</enabled></snapshots>  
  33.             </pluginRepository>  
  34.         </pluginRepositories>  
  35.     </profile>  
  36.   </profiles>  
  37.   <activeProfiles>  
  38.     <activeProfile>nexus</activeProfile>  
  39.   </activeProfiles>  
  40. </settings>  


第十一步:部署构建到Nexus,包含Release和Snapshot, 在项目根目录中pom.xml中配置:

[html] view plain copy
 print?Nexus私服搭建_01Nexus私服搭建_01
  1. <span style="font-family:Microsoft YaHei;font-size:12px;"><distributionManagement>  
  2.         <repository>  
  3.             <id>releases</id>  
  4.             <name>Internal Releases</name>  
  5.             <url>http://localhost:8080/nexus-2.9.0/content/repositories/releases/</url>  
  6.         </repository>  
  7.         <snapshotRepository>  
  8.             <id>snapshots</id>  
  9.             <name>Internal Snapshots</name>  
  10.             <url>http://localhost:8080/nexus-2.9.0/content/repositories/snapshots/</url>  
  11.         </snapshotRepository>  
  12.     </distributionManagement></span>  


第十二步:Nexus的访问权限控制,在~/m2/setting.xml中配置如下:

<!-- 设置发布时的用户名 -->

[html] view plain copy
 print?Nexus私服搭建_01Nexus私服搭建_01
  1. <span style="font-family:Microsoft YaHei;font-size:12px;"><servers>  
  2.     <server>  
  3.         <id>releases</id>  
  4.         <username>admin</username>  
  5.         <password>admin123</password>  
  6.     </server>  
  7.     <server>  
  8.         <id>snapshots</id>  
  9.         <username>admin</username>  
  10.         <password>admin123</password>  
  11.     </server>  
  12.   </servers></span>