maven私有仓库nexus3.5搭建与使用
参考网址:
http://blog.csdn.net/clj198606061111/article/details/52200928
http://www.cnblogs.com/jingmoxukong/p/6050172.html
http://blog.csdn.net/north_eagle/article/details/42428219
环境
- 操作系统 ubuntu16.04
- nexus版本 nexus-3.5.0-02-unix
下载
下载地址:https://www.sonatype.com/download-oss-sonatype
安装
$ sudo tar -zxvf nexus-3.5.0-02-unix.tar.gz -C /usr/local/
$ vim ~/.bashrc
添加
#for nexus
export NEXUS_HOME=/uusr/local/nexus-3.5.0-02
export PATH=$NEXUS_HOME/bin:$PATH
$ source ~/.bashrc
$ nexus start
打开浏览器url http://localhost:8081 用户名admin具有全部权限,默认密码admin123。
配置maven
在$MAVEN_HOME/conf下修改settings.xml
<pluginGroups>
<pluginGroup>org.sonatype.plugins</pluginGroup>
</pluginGroups>
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-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>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
使用maven编译会首先从nexus私有仓库中下载依赖包,如果nexus私有仓库没有,会从配置的mirror中maven官方中央仓库central中下载,同时存入到nexus私有仓库。
仓库迁移
nexus2.x 到nexus 2.x迁移
直接拷贝仓库目录进行迁移
当前机器上 ${user.home}/sonatype-work copy到新机器的对应位置。这样所有的数据就可以全部恢复。
nexus2.x 到nexus 3.x迁移
配置nexus-2.x的Upgrade #
Administration–>Capabilities–>New–>Upgrade: Agent–>Access Token–>12345678
上面的流程是登陆nexus-2.x配置Upgrade:Agent和Access Token在此我们配置的是12345678
配置nexus-3.x的Upgrade #
Administration–>System–>Capabilities–>Create capability–>Create Upgrade Capability
通过Task迁移数据 #
Administration–>System–>Upgrade–>Next–>URL&access token–>Next…
URL: nexus2.x的url,例如 http://10.10.3.225:8082/nexus
Access Token: 12345678
数据迁移完毕,验证仓库数据。
nexus3.x 到nexus 3.x迁移
暂时未找到方法,采用直接拷贝仓库目录进行迁移,maven编译时会有一些警告信息,并且有些包无法下载。