MAVEN配置多个仓库


问题描述:大部分jar包可从阿里云仓库获取,但是公司里有许多自用的jar包,所以这时候需要主仓库是阿里云,阿里云找不到的再到我设置的备用仓库里找。

1、配置本地仓库地址

<localRepository>D:/Maven</localRepository>

 

2、在<profiles></profiles>标签里加入阿里云和我需要的私人仓库

<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://yourIP:port/url</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>

3、启动两个仓库

<activeProfiles>
        <activeProfile>myRepository1</activeProfile>
        <activeProfile>myRepository2</activeProfile>
    </activeProfiles>

 

配置两个仓库就是这么简单,兄嘚,你学会了吗

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM