如果 Nexus 服务器关闭,如何配置 Maven 访问 Maven Central?
我想设置我的构建,以便它自动尝试从 Maven Central 下载工件,前提是我们的 Nexus 服务器无法访问。我在 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>
I would like to setup my build such that it automatically attempts to download an artifact from maven central iff our nexus server is unreachable. I have the following in settings.xml and I'm not sure how to change it (if even possible).
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使用存储库管理器(包括Nexus),您需要定义一个mirrorOf*元素,它将拦截所有存储库url并将它们发送到Nexus进行解析。在Maven2和3中,无法在配置文件中配置mirrorOf元素。这意味着没有简单的方法可以在不更改设置的情况下来回翻转。
您需要注释掉镜像部分,然后停用 Nexus 配置文件以使 Maven 恢复到标准行为。
幸运的是,Nexus 非常稳定,永远不会宕机。
In order to use a repository manager (Nexus included) you need to have a mirrorOf * element defined that will intercept all the repository urls and send them to Nexus for resolution. In Maven2 and 3, the mirrorOf element is not able to be configured in a profile. This means there is no easy way to flip back and forth without changing your settings.
You would need to comment out the mirrors section and then deactivate the Nexus profile to have Maven revert back to standard behavior.
Fortunately though Nexus is very stable and it should never go down.