Maven 存储库继承和覆盖
我有一个几年前构建的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您依赖的工件是快照版本,那么 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.