1、下载地址
https://sonatype-download.global.ssl.fastly.net/nexus/3/latest-unix.tar.gz
2、安装配置
- 启动服务,默认是 8081 端口
cd /usr/local/software/nexus-all/nexus
./bin/nexus start
- 查看启动日志
tail -f /usr/local/software/nexus-all/sonatype-work/nexus3/log/nexus.log
- 修改密码
#/usr/local/software/sonatype-work/nexus3/admin.password
查看密码,使用改密码进行登录,然后修改密码为 admin 即可
- 修改端口
cd /usr/local/software/nexus-all/nexus/etc
vim nexus-default.properties
3、docker 方式
# 拉取镜像
docker pull docker.io/sonatype/nexus3
# 创建映射目录
mkdir nexus
# 启动镜像
docker run --name nexus -p "8081:8081" -d docker.io/sonatype/nexus3
4、docker-compose 方式
version: "3"
services:
nexus:
image: sonatype/nexus3
ports:
- "8081:8081"
container_name: nexus
5、maven setting.xml 文件配置
- 镜像地址
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>local maven server</name>
<url>http://yourserver:port/nexus/content/groups/public/</url>
</mirror>
- 服务器认证
<!-- 注意, id非常重要 -->
<server>
<id>nexus</id>
<username>admin</username>
<password>admin</password>
</server>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin</password>
</server>
6、项目maven pom文件配置
- 仓库地址
<repositories>
<repository>
<id>maven-nexus</id>
<name>maven-nexus</name>
<url>http://192.168.147.130:8081/nexus/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
- 发布地址
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>nexus release</name>
<url>http://192.168.147.130:8081/nexus/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>nexus snapshot</name>
<url>http://192.168.147.130:8081/nexus/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>