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

如果nexus服务器关闭,如何配置maven以访问maven central?,maven,nexus,Maven,Nexus,我想将我的构建设置为,当nexus服务器无法访问时,它会自动尝试从maven central下载工件。我在settings.xml中有以下内容,我不知道如何更改它(如果可能的话) 关系 中心的 http://mynexus 真的 真的 中心的 http://mynexus 真的 真的 关系 为了使用存储库管理器(包括Nexus),您需要定义一个mirrorOf*元素,该元素将拦截所有存储库URL并将其发送到Nexus进行解析。在Maven2和3中,不能在概要文件中配置mirrorOf元素。这意

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


关系
中心的
http://mynexus
真的
真的
中心的
http://mynexus
真的
真的
关系

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

您需要注释掉mirrors部分,然后停用Nexus配置文件,让Maven恢复到标准行为


幸运的是,尽管Nexus非常稳定,它应该永远不会崩溃。

+1。此外,我相信他所说的“无法访问”是指“当你不在办公室,没有VPN时”。谢谢,但实际上,我所说的“无法访问”指的是更具灾难性的事情,比如托管Nexus服务器的节点上的网络问题。在这种情况下,我希望自动故障切换到maven central,以便在诊断nexus问题时不会中断构建。理论上听起来不错,但实际上没有帮助,原因如下:通常,nexus代理的不仅仅是central,还包括内部发布存储库。您可以通过组设置中的顺序以及路由规则来影响Nexus定位工件的方式。若你们突然把所有这些都抛在脑后,最好的情况是你们的开发人员会得到不同的结果,最有可能的情况是一大堆东西都找不到,导致构建失败。
<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>