我已经将"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构建应该自动使用其他位置,或者直接从mavencentral??
我不知道为什么你希望你的存储库会停机,但回到maven中心是一个非常糟糕的主意。您失去了使用公司存储库的所有好处,甚至不知道它,因为无法确定您的构建从哪里获得依赖关系。
如果您担心存储库的可用性,您应该建立一个HA环境,其中包含多个服务器,一个接一个地进行复制和备份。
如果您正在切换环境,并且一旦您处于不同的环境中,就无法再访问来自另一个intranet的二进制存储库,那么您需要通过使用不同的配置文件来切换使用二进制存储库的工作,该配置文件在新环境中可用,其中将包括不同的服务器URL(或者可能只是访问原始服务器的代理)。
无论如何,用二进制存储库屏蔽maven中心,不要将其用作备份。
如果在<repositories/>
的列表中找不到工件,Maven将自动尝试回退到Maven Central。