Nexus配置手册

一、前言

nexus的部署可参考本人另一篇博客。

Sonatype Nexus 部署手册

二、配置权限

image-20241101100520591

2.1 创建角色

这里Role Type 选择 Nexus role,使用nexus内部角色。连接外部的LDAP我们团队没有这样的需求。

image-20241101100649490

填写基本信息

选择Applied Privileges(应用权限)

image-20241101101443774

创建上述两种角色

针对于:dev-manager ⻆⾊

Nx-repository-admin-maven2 类全部勾选

Nx-repository-view-maven2 类全部勾选

针对于:dev-normal ⻆⾊

Nx-repository-admin-maven2 类只勾选 read 和browse 结尾

Nx-repository-view-maven2 类只勾选 read 和browse 结尾

image-20241101101742130

2.2 创建人员

填写基本信息

image-20241101102031136

三、创建多个三方镜像代理(proxy)仓库

华为仓库
https://repo.huaweicloud.com/repository/maven/huaweicloudsdk/
阿⾥仓库
https://maven.aliyun.com/repository/public

image-20241101102331070

创建maven私有库 hosted

image-20241101102525186

maven(group)仓库里挂载其他仓库

image-20241101102643143

四、配置本地maven仓库

获取镜像仓库地址

image-20241101103503025

修改setting.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
       <pluginGroups />
       <proxies />
       <servers>
              <server>
                     <id>ccdc-dev</id>
                     <username>dev-manager-root</username>
                     <password>******</password>
              </server>
       </servers>

       <mirrors>
              <mirror>
                     <id>ccdc-dev</id>
                     <mirrorOf>*</mirrorOf>
                     <name>私有镜像仓库</name>
                     <url>http://192.168.10.4:8081/repository/maven-public/</url>
              </mirror>
       </mirrors>
       <profiles>
              <profile>
                     <!--profile的 id-->
                     <id>ccdc-dev-profile</id>
                     <repositories>
                            <repository>
                                   <!--仓库
                                   id,repositories 可以配置多个仓库,保证 id 不重复-->
                                   <id>ccdc-dev</id>
                                   <!--仓库地址,即
                                   nexus 仓库组的地址-->
                                   <url>http://192.168.10.4:8081/repository/maven-public/</url>
                                   <!--是否下载
                                   releases 构件-->
                                   <releases>
                                          <enabled>true</enabled>
                                   </releases>
                                   <!--是否下载
                                   snapshots 构件-->
                                   <snapshots>
                                          <enabled>true</enabled>
                                   </snapshots>
                            </repository>
                     </repositories>
                     <pluginRepositories>
                            <!-- 插件仓库,maven 的运⾏依赖插件,也需要从私服下载插件 -->
                            <pluginRepository>
                                   <!-- 插件仓库的 id 不允许重复,如果重复后边配置会覆盖前边 -->
                                   <id>public</id>
                                   <url>http://192.168.10.4:8081/repository/maven-public/</url>
                                   <!--是否下载
                                   releases 构件-->
                                   <releases>
                                          <enabled>true</enabled>
                                   </releases>
                                   <!--是否下载
                                   snapshots 构件-->
                                   <snapshots>
                                          <enabled>true</enabled>
                                   </snapshots>
                            </pluginRepository>
                     </pluginRepositories>
              </profile>
       </profiles>
</settings>

五、上传jar

打开客户端

image-20241101103617520

上传附件,填写基本信息

image-20241101104036576

建议勾选“Generate a POM file with these coordinates”,便于Maven进行依赖解析和项目构建。

如果发现上传的依赖下载不了,就勾选上他重新试下。

六、获取依赖

在这个位置获取;

image-20241101104410735

复制到你本地项目的pom.xml中,刷新下maven就可以自动下载到本地了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JavaOpsPro

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值