gpt4 book ai didi

java - 使用多个公司存储库

转载 作者:搜寻专家 更新时间:2023-11-01 02:18:09 25 4
gpt4 key购买 nike

昨天我询问了有关使用独占 maven 存储库的问题,现在我需要使用 2,它们都是私有(private)的.. 所以关于 this link这解释了关于强制 maven 使用一个存储库,我如何指定第二个存储库?让我们举个例子,我的 pom.xml 现在有两个这样的存储库,如果这两个存储库中缺少某些东西,它将去搜索对公共(public)存储库的依赖,如何防止这种情况发生?

<repositories>
<repository>
<id>my-internal-site</id>
<name>our maven repository</name>
<url>http://myserver/repo</url>
</repository>
<repository>
<id>my-other-internal-site</id>
<name>our 2nd maven repository</name>
<url>http://myserver/repo2</url>
</repository>
</repositories>

我需要像这样更改设置 xml 吗?

<settings>
...
<mirrors>
<mirror>
<id>internal-repository</id>
<name>our maven repository</name>
<url>http://myserver/repo</url>
<mirrorOf>my-internal-site,my-other-internal-site</mirrorOf>
</mirror>
<mirror>
<id>my-other-internal-site</id>
<name>our 2nd maven repository</name>
<url>http://myserver/repo2</url>
<mirrorOf>my-internal-site,my-other-internal-site</mirrorOf>
</mirror>
</mirrors>
...
</settings>

或者以其他方式?

编辑

我知道如果我在 settings.xml 中指定独占的存储库,我不需要在我的 pom.xml 中设置存储库。我只是想说明一点,以便有人可以更好地回答我的问题。谢谢

最佳答案

您不需要在镜像中复制存储库 - 您说明的配置不会对给定的 mirrorOf 选择一个镜像产生任何影响。

镜像替换已定义的存储库,无论是针对给定 ID 还是 ID 集合(external:* 等)。如果需要添加存储库,则必须在 POM 或设置中添加存储库元素。

你可能想要这样的东西:

<settings>
...
<profiles>
<profile>
<id>second-repo</id>
<repositories>
<repository>
<id>second-repo</id>
<url>http://myrepo/second-repo</url>
<!-- add releases / snapshots config as appropriate here -->
</repository>
</repositories>
<!-- duplicate for pluginRepositories here if needed -->
</profile>
</profiles>
<activeProfiles>
<activeProfile>second-repo</activeProfile>
</activeProfiles>
...
<mirrors>
<mirror>
<id>corporate-repo</id>
<url>http://myrepo/my-group</url>
<mirrorOf>external:*,!second-repo</mirrorOf>
</mirror>
</mirrors>
...
</settings>

关于java - 使用多个公司存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2333183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com