Maven进阶(三):配置多仓库

二、多仓库配置方式一:全局多仓库设置

全局多仓库设置,是通过修改mavensetting文件实现。
设置思路:在setting文件中添加多个profile(也可以在一个profile中包含很多个仓库),并激活(即使是只有一个可用的profile,也需要激活)。
修改mavensetting文件,设置两个仓库(以此类推,可以添加多个):

<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)

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值