Nexus入门
安装与启动
-
下载
方式一:在liunx上直接下载
wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.11.2-03-bundle.tar.gz
方式二:下载完上传到Linux服务器
官网下载地址: https://www.sonatype.com/download-nexus-repo-oss),官网太慢的话,用下面的地址下载
百度云地址: https://pan.baidu.com/s/1r65yjGMibvKkIgstiT5K4g 提取码: bk8i
-
安装
(liunx上直接下载忽略上传步骤)
上传nexus.tar.gz到Linux服务器(也可以用fttp工具上传)
scp nexus-2.11.2-03-bundle.tar.gz root@linux ip:/usr/local/
创建安装目录
mkdir /usr/local/nexus
解压
tar -zxvf nexus-2.11.2-03-bundle.tar.gz -C /usr/local/nexus
配置(端口冲突时配置端口)
vim /usr/local/nexus/nexus-2.11.2-03/conf/nexus.properties
设置root启动(后续可更改成特定用户)
vim /usr/local/nexus/nexus-2.11.2-03/bin/nexus
将RUN_AS_USER设置成root
开放Nexus端口
firewall-cmd --zone=public --add-port=8081/tcp --permanent
重启防火墙
firewall-cmd --reload
-
启动
#启动 /usr/local/nexus/nexus-2.11.2-03/bin/nexus start
其他命令
#查看状态
/usr/local/nexus/nexus-2.11.2-03/bin/nexus status
#重启
/usr/local/nexus/nexus-2.11.2-03/bin/nexus reload
上传与配置
nexus访问地址默认为 宿主IP/配置端口(默认8081)/nexus/
右上角登陆,默认管理员账号
用户名: admin 密码: admin123
将Respository下Type为proxy的仓库配置如下设置,将Download Remote Indexes 设置成ture 点击保存。
通过Add按钮可以添加3种类型的Repository和Repository Group
Repository Group 就是Repository的集合组
Ordered Group Repositories代表这个集合组内含有的仓库 (访问顺序从上到下)
Available Repositories 代表可以添加的仓库
可以通过中间的按钮进行增加和删除两个仓库
上方的add按钮可以添加仓库和仓库组
上传jar包
maven配置
修改settings.xml中的profile 标签下添加如下配置
<profile>
<id>mynexus</id>
<repositories>
<repository>
<id>nexus</id>
<!--此地址nexus配置仓库的Repository Path -->
<url>http://192.168.2.188:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>Public Repositories</name>
<!--此地址nexus配置仓库的Repository Path -->
<url>http://192.168.2.188:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
并指定profile
<activeProfiles>
<activeProfile>mynexus</activeProfile>
</activeProfiles>
IDEA中测试能否下载上传Jar包
maven项目中添加坐标,可以看到nexus上传的文件已经下载到本地