有两种方式配置Maven多仓库
- setting.xml文件的profiles标签
- pom.xml文件的repositories标签
在使用多仓库配置时,不管使用哪种方式,必须先将setting.xml文件中的mirrors标签修改为如下内容(如果有mirrors标签),关键是mirrorOf千万不要写成*,否则多仓库配置不生效
<mirrors>
<!-- mirrorOf不要写*号,否则所有的请求都会使用此地址,此处仅仅代理默认的中央仓库 -->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
两种方式可以同时使用,setting.xml方式优先级高于pom.xml
1、setting.xml文件的profiles标签
如何配置
在setting.xml文件的settings标签中找到profiles标签(如果没有请直接新增),将其替换成如下配置(具体配置取决于自身需要的仓库)
<profiles>
<!-- 有赞仓库 -->
<profile>
<id>Youzanyun</id>
<repositories>
<repository>
<id>youzanyun-central</id>
<name>Youzan Central Repository</name>
<url>http://maven.youzanyun.com/repository/maven-central/</url>
<releases>
<enabled>true