我已将“Artifactory”设置为 Intranet maven 存储库。我有与故障转移相关的问题。
项目 POM
<repositories>
<repository>
<id>central</id>
<url>http://mvn.mycompany.com:8081/artifactory/libs-release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://mvn.mycompany.com:8081/artifactory/libs-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://mvn.mycompany.com:8081/artifactory/plugins-release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>http://mvn.mycompany.com:8081/artifactory/plugins-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
问题: 是否可以使用故障转移存储库?意思是..如果我的 Intranet 存储库已关闭,那么 Maven 构建应该自动使用其他位置或直接从 Maven Central ??
最佳答案
我不确定为什么你期望你的存储库会关闭,但是回退到 Maven Central 是一个非常糟糕的主意。您失去了使用企业存储库的所有好处,甚至不知道它,因为无法确定您的构建从何处获取依赖项。
如果您担心存储库的可用性,您应该建立具有多个服务器的 HA 环境,并逐台复制和备份。
如果您要切换环境,并且一旦处于不同的环境中,就无法再访问来自其他 Intranet 的二进制存储库,则您需要使用不同的配置文件来切换新环境中可用的二进制存储库,这将包含不同的服务器 URL(或者可能只是访问原始服务器的代理)。
无论如何 - 用您的二进制存储库遮蔽 Maven 中心,并且不要将其用作备份。
关于maven内网存储库故障转移重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17688254/