场景:私库里面认证包跟非认证同时支持下载,比如我要从my_repository仓库中下载一个groupId=ai.grakn,artifactId=redis-mock,version=0.1.6的二方包,这个包只在my_repository仓库有,除了这个包,其他的二方包都从maven-public仓库下载,配置如下:
1、pom.xml配置如下
<repositories>
<repository>
<id>my-repository</id>
<url>http://nexus.xxx.com/repository/my_repository/</url>
</repository>
</repositories>
2、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">
<localRepository>D:\MyData\zouwei5\.m2\repository</localRepository>
<servers>
<server>
<id>my-repository</id>
<username>admin</username>
<password>admin#ttrtrt</password>
</server>
</servers>
<mirrors>
<mirror>
<id>maven-public</id>
<url>http://nexus.xxx.com/repository/maven-public/</url>
<mirrorOf>!my-repository,*</mirrorOf>
</mirror>
</mirrors>
</settings>

本文介绍了如何配置Maven的pom.xml和settings.xml,以实现从私有仓库my_repository下载特定的ai.grakn:redis-mock:0.1.6包,同时其他依赖从maven-public仓库获取。配置包括在pom.xml中声明私有仓库,并在settings.xml中设置认证信息及镜像配置,确保正确下载所有依赖。
1万+

被折叠的 条评论
为什么被折叠?



