【Maven】配置多个仓库(第三方和公司内部仓库)

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">

  <localRepository>D:\Develop\.m2\repository</localRepository>

  <mirrors>
    <!-- 删除mirrors里的配置,改用profiles -->
  </mirrors>

  <profiles>
    <!-- 多仓库配置  -->
    <!-- 阿里云 -->
    <profile>
      <id>aliyun</id>
      <repositories>
        <repository>
          <!-- 注意:repository的id不要重复,否则先解析的配置会被后解析的覆盖 -->
          <id>aliyun-public</id>
          <url>https://maven.aliyun.com/repository/public/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>

    <!-- 公司内网 -->
    <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>nexus-public</id>
          <url>http://公司仓库地址</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>nexus-central</id>
          <url>http://公司仓库地址</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>

  <!-- 需要默认激活的远程镜像仓库配置 -->
  <activeProfiles>
    <activeProfile>aliyun</activeProfile>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

</settings>

posted @ 2024-03-27 03:03  中国制造  阅读(520)  评论(2编辑  收藏  举报