maven - 多存储库查找配置

maven - multiple repository lookup configuration

我正在为我的项目使用 maven v3.0.1。我的项目依赖于公司远程存储库中的工件。此外,我在公司中有一个本地存档存储库,其中包含本地工件,这些工件不在公司远程存储库中。

我想 settings.xml 这样的方式,对于所有项目,它将首先在公司远程存储库中查找指定的工件,如果在那里没有找到,则在本地档案库。

我在 <repository> 标签中添加了本地存储库并为 <activeProfile> 启用了配置文件。但是查找并没有按预期发生。分析发现 mirrorOf 设置在那里起作用。以下是我的 settings.xml。

<?xml version="1.0" encoding="UTF-8"?>
<settings>
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://corporate-repo:8081/nexus/content/groups/public</url>
      </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>nexus</id>
      <repositories>

        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
          </snapshots>
        </repository>

        <repository>
            <id>spring-snapshot</id>
            <name>Spring Maven SNAPSHOT Repository</name>
            <url>http://repo.springsource.org/libs-snapshot</url>
        </repository>

        <repository>
            <id>internal</id>
            <name>Local Release Repository</name>
            <url>http://local-repo:8081/repository/internal</url>
        </repository>

      </repositories>

      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>  

</settings>

如何修改 settings.xml 以根据需要进行查找?是否可以在 mirrorOf 设置中提供两个 url。我试过了

<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://corporate-repo:8081/nexus/content/groups/public,http://local-repo:8081/repository/internal</url>
</mirror>

xml 解析中没有错误,但查找不工作。谁能阐明如何解决这个问题

我尝试了很多选项,最后通过将 mirrorOf 设置调整为 <mirrorOf>*,!internal</mirrorOf>

解决了

所以镜像设置是,

 <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*,!internal</mirrorOf>
      <url>http://corporate-repo:8081/nexus/content/groups/public</url>
      </mirror>
  </mirrors>

* 确保对于除内部回购之外的所有请求 !internal 在公司回购中进行查找。对于内部回购,请在配置有存储库 ID 的本地回购中查找 internal