二、多仓库配置方式一:全局多仓库设置
全局多仓库设置,是通过修改maven
的setting
文件实现。
设置思路:在setting
文件中添加多个profile
(也可以在一个profile
中包含很多个仓库),并激活(即使是只有一个可用的profile
,也需要激活)。
修改maven
的setting
文件,设置两个仓库(以此类推,可以添加多个):
<profiles>
<profile>
<!-- id必须唯一 -->
<id>myRepository1</id>
<repositories>
<repository>
<!-- id必须唯一 -->
<id>myRepository1_1</id>
<!-- 仓库的url地址 -->
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>;
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<!-- id必须唯一 -->
<id>myRepository2</id>
<repositories>
<repository>
<!-- id必须唯一 -->
<id>myRepository2_1</id>
<!-- 仓库的url地址 -->
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>;
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<!-- 激活myRepository1 -->
<activeProfile>myRepository1</activeProfile>
<!-- 激活myRepository2 -->
<activeProfile>myRepository2</activeProfile>
</activeProfiles>
三、多仓库配置方式二:在项目中添加多个仓库
在项目中添加多个仓库,是通过修改项目中的pom
文件实现的。
思路:在项目中pom
文件的repositories
节点(如果没有手动添加)下添加多个repository
节点,每个repository
节点是一个仓库。
修改项目中pom
文件,设置两个仓库(以此类推,可以添加多个):
<repositories>
<repository>
<!-- id必须唯一 -->
<id>jboss-repository</id>
<!-- 见名知意即可 -->
<name>jboss repository</name>
<!-- 仓库的url地址 -->
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>;
</repository>
<repository>
<!-- id必须唯一 -->
<id>aliyun-repository</id>
**读者福利**
========
**[开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】](https://bbs.csdn.net/topics/618166371)**
> **由于篇幅过长,就不展示所有面试题了,想要完整面试题目的朋友(另有小编自己整理的2024大厂高频面试题及答案附赠)**
> ![](https://img-blog.csdnimg.cn/20201126205036657.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3NpbmF0XzM3OTAzNDY4,size_16,color_FFFFFF,t_70)
> ![](https://img-blog.csdnimg.cn/20201126205047777.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3NpbmF0XzM3OTAzNDY4,size_16,color_FFFFFF,t_70)
> ![](https://img-blog.csdnimg.cn/20201126205051391.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3NpbmF0XzM3OTAzNDY4,size_16,color_FFFFFF,t_70)