Maven 存储库继承和覆盖

发布于 2024-11-15 10:54:13 字数 297 浏览 0 评论 0原文

我有一个几年前构建的 Maven 项目,现在我需要进行一些更新。我的项目的依赖项之一在其 POM 中列出了一个不再存在的 Maven 存储库。我现在遇到构建失败。

我本以为我的 POM 或 Settings.xml 中的存储库列表会胜过依赖项的 POM 中列出的任何存储库;或者 Maven 会在无法连接到已消失的存储库后尝试我的存储库。相反,它只是因构建失败而崩溃。

此外,我的本地存储库中已经有了所需的依赖项。我还以为 Maven 会使用它。

有没有办法覆盖继承的存储库列表,或者告诉 Maven 在存储库问题的情况下继续执行?

I have a Maven project that was built a few years back, and now I need to make some updates. One of the dependencies to my project has a Maven repository listed in its POM that no longer exists. I get build failures now.

I would have thought the repository listings in my POM or Settings.xml would trump any repositories listed in a dependency's POM; or Maven would try my repositories after failing to connect to the extinct repository. Instead, it just bombs out with a build failure.

Additionally, I already have the required dependencies in my local repository. I would have additionally thought that Maven would just use that.

Is there a way to override the inherited repository listings, or tell Maven to carry-on in the case of a repo problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖微凉心微凉 2024-11-22 10:54:13

如果您依赖的工件是快照版本,那么 maven 将在每次构建时检查新快照,这就是为什么将依赖项锁定到已发布版本是一个很好的做法。

您可以通过在 settings.xml 中定义 来“覆盖”存储库声明。

请参阅 http://maven.apache.org/settings.html#Mirrors

我通常设置启动本地托管的存储库管理器(最好nexus),然后定义mirrorOf(*) = local-repo-manager/网址。
Nexus 允许使用预定义的搜索顺序对多个存储库进行分组。
Nexus 存储库可以本地托管或缓存/代理到公共存储库。
我通常在组的前面有一个本地托管的第 3 方存储库,我可以在其中存储未在公共存储库上发布的工件。

If the artifact that you depend on is a snapshot version then maven will check for a new snapshot every time you build, thats why it is a good practice to lock down your dependencies to a released version.

You can "override" the repository declarations by defining a <mirror> in the settings.xml.

See http://maven.apache.org/settings.html#Mirrors

I usually set up a locally hosted repository manager (preferably nexus) and then define mirrorOf(*) = local-repo-manager/url.
Nexus allows multiple repo's to be grouped with a predefined search order.
Nexus repo's can be locally hosted or caching/proxies to public repo's.
I usually have a locally hosted 3rd party repo at the front of the group, where I can store artifacts that are not published on public repo's.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文