环境说明:
系统:centos7
nexus版本:nexus-2.14.5-02-bundle.tar.gz
nexus 下载安装
nexus 下载地址:
https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.5-02-bundle.tar.gz
百度网盘:
链接:https://pan.baidu.com/s/1rninTQZfwHQq4YxjiKtdaQ
提取码:mrq8
具体步骤:
1、创建文件夹,并进入文件夹
mkdir -p /usr/local/nexus
cd /usr/local/nexus
2、获取安装包,若获取不到,请从百度网盘下载后上传
wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.5-02-bundle.tar.gz
3、解压
tar -zxvf nexus-2.14.5-02-bundle.tar.gz
4、查看并修改配置文件,application-port:8081为默认端口,若需要修改,则修改这个
cd nexus-2.14.5-02/
vim conf/nexus.properties
5、修改使用用户账号
vim bin/nexus
#将RUN_AS_USER= 注解放开,并改成"root"
6、启动
bin/nexus start
7、访问地址:
http://ip:8081/nexus/#welcome
8、停止
bin/nexus stop
9、其他说明
默认账号:
admin/admin123
deployment/deployment123
nexus 仓库介绍
3rd party:第三方仓库
Apache Snapshots:apache 快照仓库
Central: maven 中央仓库
Releases:私有发布版本仓库
Snapshots:私有 快照版本仓库
本地远程仓库配置
或者在settings.xml 文件中配置远程仓库镜像 效果一样,但作用范围广了
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://192.168.0.147:8081/nexus/content/groups/public/</url>
</mirror>
添加用户
<server>
<id>nexus-snapshot</id>
<username>deployment</username>
<password>deployment123</password>
</server>
上传jar包
mvn deploy:deploy-file -DgroupId=com.fasterxml.jackson.core -DartifactId=jackson-databind -Dversion=2.5.0 -Dpackaging=jar -Dfile=jackson-annotations-2.5.0.jar -Durl=http://192.168.0.141:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=nexus-snapshot
DgroupId、DartifactId、Dversion:构成了该jar包在pom.xml的坐标,自己起名字也是可以的.
Dpackaging:表示打包类型
Dfile:表示需要上传的jar包的绝对路径
Durl:私服上第三方仓库的地址,打开nexus——>repositories菜单,可以看到该路径
DrepositoryId:服务器的表示id,就是我们在setting.xml文件中配置的serverId
执行成功表示已经上传到Nexus私服了.
之后,项目组成员,只要在修改maven的setting.xml,添加私服的地址,就可以正常使用私服的jar包了