2

我已将“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 中心?

4

2 回答 2

2

我不确定您为什么希望您的存储库关闭,但是回退到 maven Central 是一个非常糟糕的主意。您失去了使用公司存储库的所有好处,甚至不知道它,因为无法确定您的构建从哪里获取依赖项。

如果您担心存储库的可用性,则应建立具有多个服务器的 HA 环境,并逐个复制和备份。

如果您正在切换环境并且一旦您处于不同的环境中,则无法再访问来自其他 Intranet 的二进制存储库,您需要使用不同的配置文件切换使用在新环境中可用的二进制存储库,其中将包括不同的配置文件服务器网址(或者可能只是访问原始服务器的代理)。

无论如何 - 用您的二进制存储库遮蔽 maven 中心,不要将其用作备份。

于 2013-07-17T10:46:55.503 回答
1

如果在 列表中找不到工件<repositories/>,Maven 将自动尝试回退到 Maven Central。

于 2013-07-17T01:37:05.200 回答