| 备注 | 修改日期 | 修改人 |
| 创建版本 | 2025-11-24 16:28:40[当前版本] | 文艺范儿 |
官网:
下载地址:https://links.sonatype.com/products/nxrm3/download-unix-x86
# 系统要求 操作系统: CentOS 7.x/8.x 或 Ubuntu 18.04+ 内存: 至少4GB 磁盘: 至少50GB可用空间 Java: JDK 8+ # 创建专用用户 [root@202-nexus ~]# groupadd nexus [root@202-nexus ~]# useradd -g nexus -s /bin/bash -d /home/nexus -m nexus
# 此处不做描述 ##验证java [root@202-nexus ~]# java -version java version "21.0.9" 2025-10-21 LTS Java(TM) SE Runtime Environment (build 21.0.9+7-LTS-338) Java HotSpot(TM) 64-Bit Server VM (build 21.0.9+7-LTS-338, mixed mode, sharing)
# 创建安装目录 [root@202-nexus ~]# mkdir /home/deploy/nexus [root@202-nexus ~]# chown -R nexus:nexus /home/deploy/nexus # 切换用户 [root@202-nexus ~]# su - nexus # 下载Nexus(最新版本) [nexus@202-nexus ~]$ cd /home/deploy/nexus/ [nexus@202-nexus nexus]$ wget https://download.sonatype.com/nexus/3/nexus-3.86.2-01-linux-x86_64.tar.gz # 解压 [nexus@202-nexus nexus]$ tar xf nexus-3.86.2-01-linux-x86_64.tar.gz [nexus@202-nexus nexus]$ ln -s nexus-3.86.2-01 nexus # 创建数据目录 [nexus@202-nexus nexus]$ mkdir /home/deploy/nexus/data
# 编辑Nexus配置文件 [nexus@202-nexus nexus]$ vim /home/deploy/nexus/nexus/etc/nexus-default.properties ... ## 数据目录 nexus.data=/home/deploy/nexus/data ...
# 创建systemd服务文件 [root@202-nexus ~]# vim /etc/systemd/system/nexus.service [root@202-nexus ~]# cat /etc/systemd/system/nexus.service [Unit] Description=nexus service After=network.target [Service] Type=forking LimitNOFILE=65536 User=nexus Group=nexus ExecStart=/home/deploy/nexus/nexus/bin/nexus start ExecStop=/home/deploy/nexus/nexus/bin/nexus stop Restart=on-abort TimeoutSec=600 [Install] WantedBy=multi-user.target
# 设置权限 [root@202-nexus ~]# chown -R nexus:nexus /home/deploy/nexus # 重新加载systemd [root@202-nexus ~]# systemctl daemon-reload # 启动服务 [root@202-nexus ~]# systemctl start nexus [root@202-nexus ~]# systemctl enable nexus # 检查状态 [root@202-nexus ~]# systemctl status nexus # 查看启动日志 [root@202-nexus ~]# tail -f /home/deploy/nexus/sonatype-work/nexus3/log/nexus.log
# 访问Nexus Web界面 # 地址: http://your-server-ip:8081 # 获取初始管理员密码 [root@202-nexus ~]# cat /home/deploy/nexus/sonatype-work/nexus3/admin.password # 初始配置步骤: # 1. 使用admin和上面获取的密码登录 # 2. 修改管理员密码 # 3. 配置匿名访问(根据安全需求)
在Nexus中创建以下仓库:
代理仓库(Proxy Repositories)
这里只配置代理仓库即可,在页面操作
# 常用代理仓库 - maven-central: https://repo1.maven.org/maven2/ - aliyun-maven: https://maven.aliyun.com/repository/public/ - jcenter: https://jcenter.bintray.com/
托管仓库(Hosted Repositories)
# 发布版本仓库 - maven-releases (Version policy: Release) # 快照版本仓库 - maven-snapshots (Version policy: Snapshot) # 第三方库仓库 - maven-3rdparty (Version policy: Mixed)
仓库组(Repository Groups)
# 创建仓库组,包含所有需要的仓库 - maven-public (包含: maven-central, aliyun-maven, maven-releases, maven-snapshots)
在项目的pom.xml或settings.xml中配置:
settings.xml配置示例
#已经去掉所有注释,修改前先备份
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>my-nexus-releases</id>
<username>admin</username>
<password>dong123456</password>
</server>
<server>
<id>my-nexus-snapshot</id>
<username>admin</username>
<password>dong123456</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://10.0.0.202:8081/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://10.0.0.202:8081/repository/maven-public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://10.0.0.202:8081/repository/maven-public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>