Nexus私有仓库搭建说明文档(实用型)

Nexus私有仓库搭建说明文档

背景

最近在研究SpringBoot 自定义starter,为了方便starter管理和共享,故查阅资料构建私有仓库管理

准备环境


1、修改nexus解压文件中/bin/nexus文件,添加内容【jdk路径见下方详情】
INSTALL4J_JAVA_HOME_OVERRIDE="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin"
2、如果是使用是Maven仓库服务器的,请修改/etc/systemd/system.conf和/etc/systemd/user.conf文件,修改文件内容如下所示,非maven仓库谨慎操作
DefaultLimitNOFILE=65536


Nexus下载

下载链接:https://pan.baidu.com/s/1mQHUaNb0nGFyFULn0dQ5YA
提取码:w2pw

使用yum或者apt安装jdk,安装路径命令查看如下


[root@localhost etc]# which java
/usr/bin/java
[root@localhost etc]# ls -lrt /usr/bin/java
lrwxrwxrwx. 1 root root 22 Jun  7 15:45 /usr/bin/java -> /etc/alternatives/java
[root@localhost etc]# ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 73 Jun  7 15:45 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.x86_64/jre/bin/java 【温馨提醒,配置Nexus环境,把"java"去掉】

Nexus运行

当前采用的是root用户运行,同鞋们可以选择其他用户运行,最好是可以做成Service服务启动


# 进入nexus目录,查看执行命令
[root@localhost nexus]# ./bin/nexus
WARNING: ************************************************************
WARNING: Detected execution as "root" user.  This is NOT recommended!
WARNING: ************************************************************
Usage: ./bin/nexus {start|stop|run|run-redirect|status|restart|force-reload}

# 启动nexus
[root@localhost nexus]# ./bin/nexus start


防火墙规则

Nexus 默认端口:8081

具体命令使用 man ufw[ufw 是示例命令],查看使用详情


# 第一种情况,如果是公司内网环境或者个人VM虚拟机,可以选择开放8081防火墙墙端口,或者关闭防火墙[个人环境推荐使用,省了很多麻烦]
# Centos 
# --permanent永久生效,没有此参数重启后失效
firewall-cmd --zone=public --add-port=8081/tcp --permanent
# 重新载入规则
firewall-cmd --reload

# Ubunt
ufw allow 8081
ufw reload

# 第二种情况,如果是云服务器,则需要去云服务器控制台配置防火墙规则


Nexus管理页面操作

国内代理中央仓库配置

  • 浏览器输入地址:http://IP:8081,IP为安装Nexus对应服务器的IP
  • 界面会提示到服务器路径/usr/local/sonatype-work/nexus3/password.* 文件查看默认密码,输入默认密码后需要重置新密码便可进入系统
  • 添加aliyun代理仓库
    在这里插入图片描述

在这里插入图片描述

没有”save“ 按钮,是”Create repository“ !!!

在这里插入图片描述

  • 在私有仓库中添加刚才创建的aliyun代理maven仓库

在这里插入图片描述

在这里插入图片描述

到此为止 nexus配置就基本完成了

仓库查看

在这里插入图片描述
在这里插入图片描述

Maven的settings.xml文件配置

当前以window配置环境为示例

在这里插入图片描述

温馨提示:本地仓库路径配置,如果不配置默认将jar包安装到系统盘C目录下,暂用大量系统盘存储空间

<!--- 在<settings>标签下,添加下面目录,目录地址可以自定义 --->
<localRepository>D:\\maven\\repository2</localRepository>
<!--- 配置Nexus 账号密码 --->
<server>
    <id>releases</id>
    <username>admin【nexus账号密码】</username>
    <password>****【nexus账号密码】</password>
</server>
<server>
    <id>snapshots</id>
    <username>admin【nexus账号密码】</username>
    <password>****【nexus账号密码】</password>
</server>
<!--- 配置私有仓库代理,由于我们在私有仓库中添加了国内代理仓库了,<mirrors> 标签下就不需要配置国内代理仓库了 --->
<mirror>
    <id>nexus-repository</id>
    <mirrorOf>central</mirrorOf>
    <name>Nexus repository</name>
    <url>http://192.168.##.##:8081/repository/maven-public/</url>
</mirror>

SpringBoot项目配置

  • pom.xml配置

温馨提醒:如果出现 标签报错,请手动敲入【童鞋们切记,切记】

<distributionManagement>
    <repository>
        <id>releases</id>
        <name>Nexus Release Repository</name>
        <url>http://192.168.44.165:8081/repository/maven-releases/</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>Nexus Snapshot Repository</name>
        <url>http://192.168.44.165:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
</distributionManagement>
  • maven环境配置

在这里插入图片描述

在这里插入图片描述

  • 打包项目
    在这里插入图片描述

  • 本地jar更新到私有仓库nexus

在这里插入图片描述

温馨提醒:到这里已经基本掌握Nexus私有maven仓库的搭建和使用了,其他密码明文加密需要童鞋们自行研究了。

好好学习,天天向上 ——《毛主席》

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值