如果nexus服务器关闭,如何配置maven访问maven中心?

Jen*_*key 5 nexus maven

我想设置我的构建,如果我们的nexus服务器无法访问,它会自动尝试从maven中心下载工件.我在settings.xml中有以下内容,我不知道如何更改它(如果可能的话).

<profiles>
<profile>
 <id>nexus</id>
 <!--Enable snapshots for the built in central repo to direct -->
 <!--all requests to nexus via the mirror -->
 <repositories>
   <repository>
     <id>central</id>
     <url>http://mynexus</url>
     <releases><enabled>true</enabled></releases>
     <snapshots><enabled>true</enabled></snapshots>
   </repository>
 </repositories>
 <pluginRepositories>
   <pluginRepository>
     <id>central</id>
     <url>http://mynexus</url>
     <releases><enabled>true</enabled></releases>
     <snapshots><enabled>true</enabled></snapshots>
   </pluginRepository>
 </pluginRepositories>
</profile>
</profiles>

<activeProfiles>
   <activeProfile>nexus</activeProfile>
</activeProfiles>
Run Code Online (Sandbox Code Playgroud)

Bri*_*Fox 2

为了使用存储库管理器(包括Nexus),您需要定义一个mirrorOf*元素,它将拦截所有存储库url并将它们发送到Nexus进行解析。在Maven2和3中,无法在配置文件中配置mirrorOf元素。这意味着没有简单的方法可以在不更改设置的情况下来回翻转。

您需要注释掉镜像部分,然后停用 Nexus 配置文件以使 Maven 恢复为标准行为。

幸运的是,Nexus 非常稳定,永远不会宕机。