zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    Gin框架结合gorm实现mysql增删改查
    Gin框架安装使用
    Golang常用排序算法比较
    Golang获取时间戳及格式化
    Golang使用goroutine交替打印序列
    Golang基础编程(六)-并发编程
    Golang基础编程(五)-指针
    Golang基础编程(四)-Map(集合)、Slice(切片)、Range
    模块化前端开发入门指南(三)
    模块化前端开发入门指南(二)
  • 原文地址:https://www.cnblogs.com/panchanggui/p/14704334.html
Copyright © 2011-2022 走看看