一、前言
nexus的部署可参考本人另一篇博客。
二、配置权限
2.1 创建角色
这里Role Type 选择 Nexus role,使用nexus内部角色。连接外部的LDAP我们团队没有这样的需求。
填写基本信息
选择Applied Privileges
(应用权限)
创建上述两种角色
针对于:dev-manager ⻆⾊
Nx-repository-admin-maven2 类全部勾选
Nx-repository-view-maven2 类全部勾选
针对于:dev-normal ⻆⾊
Nx-repository-admin-maven2 类只勾选 read 和browse 结尾
Nx-repository-view-maven2 类只勾选 read 和browse 结尾
2.2 创建人员
填写基本信息
三、创建多个三方镜像代理(proxy)仓库
华为仓库
https://repo.huaweicloud.com/repository/maven/huaweicloudsdk/
阿⾥仓库
https://maven.aliyun.com/repository/public
创建maven私有库 hosted
maven(group)仓库里挂载其他仓库
四、配置本地maven仓库
获取镜像仓库地址
修改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
打开客户端
上传附件,填写基本信息
建议勾选“Generate a POM file with these coordinates”,便于Maven进行依赖解析和项目构建。
如果发现上传的依赖下载不了,就勾选上他重新试下。
六、获取依赖
在这个位置获取;
复制到你本地项目的pom.xml中,刷新下maven就可以自动下载到本地了。