mvn 配置多个数据源同时使用

使用配置文件激活实现多仓库下载
在 Maven 配置文件中配置的 部分定义了 Maven 镜像的设置。
镜像的作用是在构建过程中,将对中央仓库(Central Repository)的访问请求重定向到镜像仓库,从而加速依赖项的下载过程,减轻中央仓库的负载,以及提供备用的下载源。
修改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>

因设置的mirrorOf为central,如果我随便设置一个参数,如abc,这时候我们配置的仓库就不起作用了,
这是因为maven默认内置了如下一个仓库,这个默认仓库的id为central,当我们把mirrorOf设置为central时,
maven就会查找有没有id为central的仓库,然后把id为central的仓库地址换成我们标签配置的那个url,这样我们配置的mirror才会起作用。
当然我们也可以把mirrorOf设置为*,表示所有仓库都使用我们配置的这个mirror作为jar包下载地址。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值