一:使用nexus来创建局域网的仓库
1.1下载nexus
1.2解压,并设置bin目录到环境变量
1.3配置nexus的nexus-2.3.1-01\bin\jsw\conf下的wrapper.conf;设置本地java路径;如图
1.4以管理员身份运行cmd.exe,执行nexus install
1.5安装成功后在cmd中执行nexus start
1.6启动成功后在浏览器地址栏访问:http://localhost:8081/nexus/index.html
1.7登录本地的nexus
用户名:admin
密码:admin123
二:创建局域网的仓库
仓库管理:
1.nexus的仓库类型讲解
2.创建私有仓库
2.1添加parent的使用仓库
修改本地maven的配置;setting文件位置:
<mirrors>
<mirror>
<id>central</id>
<mirrorOf>*</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://192.168.0.199:8081/nexus/content/groups/public/</url>
</mirror>
2.2更新索引,将download Remote Indexes设置为true
保存之后去查看当前任务列表
完成后再进行搜索就可以使用了
2.3删除parent中的工厂设置,在settings.xml中进行工厂的设置
<profiles>
<profile>
<id>central-repos</id>
<repositories>
<repository>
<id>central</id>
<name>Central</name>
<url>http://central</url>
<releases><enable>true</enable></releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
其中url在配置完镜像之后就没有意义了。配置完成之后需要进行激活,开启如下代码
<activeProfiles>
<activeProfile>central-repos</activeProfile>
</activeProfiles>
2.4项目的发布
然后修改parent的pom.xml文件,添加如下代码:
<distributionManagement>
<snapshotRepository>
<id>user-snapshots</id>
<name>User Project SNAPSHOTS</name>
<url>http://192.168.0.199:8081/nexus/content/repositories/MyUserReposSnapshots/</url>
</snapshotRepository>
<repository>
<id>user-releases</id>
<name>User Project Release</name>
<url>http://192.168.0.199:8081/nexus/content/repositories/MyUserReposRelease/</url>
</repository>
</distributionManagement>
在settings文件上面添加用户信息。给用户指定的权限
<servers>
<server>
<id>user-snapshots</id>
<username>kh</username>
<password>123456</password>
</server>
<server>
<id>user-releases</id>
<username>kh</username>
<password>123456</password>
</server>
然后在parent的pom.xml上执行maven build 输入或执行clean deploy;