Maven配置多个远程仓库的实现方法

起因

由于公司原因,很多jar包都是内部开源,外部非开源情况,所以很多jar包都在aliyun的远程仓库中找不到。但是又因为回家后,自己写的很多demo都是用的一些公司仓库里没有的jar。所以就想着配置多个Maven仓库镜像地址,从而解决反复切换仓库一问题。

<mrrior></mrrior>配置多个镜像问题

这里必须要提醒!mrrior标签配置多个,生效的只有第一个!只有第一个仓库无法访问的时候,才会使用第二个。注意是无法访问的时候,如果能访问,但是仓库中没有你要找的包,他不会去访问第二个仓库!

<profile></profile>配置多镜像

这里推荐使用profile属性进行多镜像配置。

 <profiles>
	<profile>
        <!-- id必须唯一 -->
        <id>aliyunRepository</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>companyRepository</id>
        <repositories>
            <repository>
                <!-- id必须唯一 -->
                <id>myRepository2_1</id>
                <!-- 仓库的url地址 -->
                <url>你们另一个仓库的地址</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </repository>
        </repositories>
    </profile>
  </profiles>

    <activeProfiles>
    <!-- 激活myRepository2 -->
    <activeProfile>companyRepository</activeProfile>
	<!-- 激活myRepository1 -->
    <activeProfile>aliyunRepository</activeProfile>
  </activeProfiles>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值