安装
nexus-3.31.1-01-unix.tar.gz
链接:https://pan.baidu.com/s/1YrJMwpGxmu8N2d7XMl6fSg
提取码:kfeh
上传到服务器,解压
tar -zvxf nexus-3.31.1-01-unix.tar.gz
进入bin目录,启动
./nexus start
查看状态
./nexus status
默认8081端口,访问地址 http://ip:8081/
设置开机自启
首先需要确认nexus的安装目录,这里使用的目录为/opt/nexus-3.31.1-01,权限配置为nexus用户所有。
在三个文件夹其中一个创建nexus.service文件,优先级是/etc/systemd/ > /usr/lib/systemd/ > /lib/systemd/
[Unit]
Description=nexus service
After=network.target[Service]
Type=forking
ExecStart=/opt/nexus-3.31.1-01/bin/nexus start
ExecStop=/opt/nexus-3.31.1-01/bin/nexus stop
User=nexus #启动nexus进程的用户,需要确认目录是否有访问权限
Restart=on-abort[Install]
WantedBy=multi-user.target #命令行模式
执行以下命令
systemctl daemon-reload
systemctl enable nexus
systemctl start nexus
点击登录会提示修改密码,按提示命令执行
配置拉取
一般使用maven-public,maven-central会去拉公共仓库,拉完maven-public中就能用,其实就是代理
maven-releases是正式的jar包
maven-snapshots是快照的jar包
在pom.xml中配置如下
<repositories>
<repository>
<id>public</id>
<name>nexus</name>
<url>http://192.168.56.203:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>nexus</name>
<url>http://192.168.56.203:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
配置上传
在maven的settings.xml中配置
<servers>
<server>
<id>maven-releases</id>
<username>admin</username>
<password>chenxb123456</password>
</server>
<server>
<id>maven-snapshots</id>
<username>admin</username>
<password>chenxb123456</password>
</server>
</servers>
在pom.xml中配置如下
<distributionManagement>
<repository>
<id>maven-releases</id>
<url>http://192.168.56.203:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>maven-snapshots</id>
<url>http://192.168.56.203:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
version标签中是SNAPSHOT则上传到maven-snapshots,releases则上传到maven-releases
点击maven deploy,如下图上传成功