具有多个镜像的 Maven 项目上的依赖项下载错误
当我尝试使用 Maven 构建项目时遇到问题。我的网络上有一个 Nexus 服务器,我的所有依赖项都来自那里。它有一个中央存储库,它是外部依赖项的官方 maven2 存储库的代理,还有一个存储此处所有内部库的存储库。
好吧,让我们直接讨论问题吧。我的 .m2 文件夹上有以下配置:
<settings>
<mirrors>
<mirror>
<id>treto</id>
<name>Tre-to Libs</name>
<url>http://10.163.40.41:8081/nexus/content/repositories/treto-libs/</url>
<mirrorOf>treto-libs,br.jus.treto</mirrorOf>
</mirror>
<mirror>
<id>central</id>
<name>Maven Repository Manager</name>
<url>http://10.163.40.41:8081/nexus/content/repositories/central/</url>
<mirrorOf>central,!treto-libs,!br.jus.treto</mirrorOf>
</mirror>
</mirrors>
...
</settings>
在我的项目的 pom 上,我有以下依赖项,这是我从 nexus 界面复制的代码:
<dependencies>
<dependency>
<groupId>br.jus.treto</groupId>
<artifactId>tre-auth</artifactId>
<version>0.120</version>
</dependency>
</dependencies>
该依赖项应该从“treto”镜像下载,但 Maven 始终是尝试从中央镜像获取它,而中央镜像没有这种依赖性。
问题是,我在配置中缺少什么?
I'm having a problem when I'm trying to build a project with Maven. I have a nexus server on my network and all my dependencies comes from there. It have a central repository which is a proxy to the oficial maven2 repository for external dependencies and a repository that store all internal libraries from here.
Well, let's jump to the problem. I have the following configuration on my .m2 folder:
<settings>
<mirrors>
<mirror>
<id>treto</id>
<name>Tre-to Libs</name>
<url>http://10.163.40.41:8081/nexus/content/repositories/treto-libs/</url>
<mirrorOf>treto-libs,br.jus.treto</mirrorOf>
</mirror>
<mirror>
<id>central</id>
<name>Maven Repository Manager</name>
<url>http://10.163.40.41:8081/nexus/content/repositories/central/</url>
<mirrorOf>central,!treto-libs,!br.jus.treto</mirrorOf>
</mirror>
</mirrors>
...
</settings>
And on my project's pom I have the following dependency, which the code I copied from the nexus interface:
<dependencies>
<dependency>
<groupId>br.jus.treto</groupId>
<artifactId>tre-auth</artifactId>
<version>0.120</version>
</dependency>
</dependencies>
This dependency is supposed to be downloaded from the "treto" mirror, but Maven is always trying to get it from the central mirror, which doesn't have that dependency.
The question is, what am I missing on the configuration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该在 pom.xml 或 settings.xml (在配置文件中)中具有这种声明:
然后,您的镜像应该是:
您可以告诉 Maven 将镜像用于除 treto 之外的所有内容:
或者仅将其用于中央
如果这不起作用,请发布完整的 pom 和设置;);)
You should have, in you pom.xml or settings.xml (in a profile), this kind of declaration :
Then, your mirrors should be :
You can tell maven to use your mirror for everything except treto:
or only use it for central
Post your full pom and settings if this don't work ;);)
您的项目或设置中是否声明了具有 ids(treto-libs、br.jus.treto)的存储库?
因为你说mirrorOf必须声明那些id。
does repositories with ids (treto-libs,br.jus.treto) are declared in your project or settings ?
Because you say mirrorOf those ids must be declared.