简体   繁体   English

Nexus从Maven Central而不是从3rd Party取得Jar

[英]Nexus takes jar from maven central, not from 3rd party

We have a problem at our project, where the pom file of the downloaded jar is not correct. 我们的项目出现问题,下载的jar的pom文件不正确。 It does not contain a 1.0 tag. 它不包含1.0标签。 So what we did was installing our "corrected" pom file for that library and added is a 3rd party library to nexus. 因此,我们要做的是为该库安装“更正”的pom文件,并向Nexus添加了一个第三方库。

The problem we are now facing is that it does not take the version that we added as a 3rd party library. 我们现在面临的问题是,它并没有采用我们作为第三方库添加的版本。 In a similar case, when we deleted the file out of the maven central nexus repository, than it took the 3rd party library, and it did not try to fetch it again from maven central. 在类似的情况下,当我们从Maven Central Nexus存储库中删除文件时,它占用了第3方库,并且它没有尝试再次从Maven Central获取文件。

Now we did the same for a corrupted jar, but when we delete the jar in the openSAML nexus repository, instead of using the 3rd party library, it refetches it from the openSAML nexus repository and it does not take ours. 现在,我们对损坏的jar进行了相同的操作,但是当我们在openSAML nexus存储库中删除该jar时,它没有使用3rd party库,而是从openSAML nexus存储库中重新提取了它,而没有使用我们的第三方库。

Does anyone have an idea to why it refetches it and does not take the 3rd party library? 有谁知道为什么要重新提取它而不使用第3方库?

Try this. 尝试这个。 Remove the jar form your local repository. 从本地存储库中删除jar。 Now go to maven settings and temporarily remove entry for openSAML repository. 现在转到maven设置并临时删除openSAML存储库的条目。 Now build your project, it will now download jar from 3rd party nexus repository [Note that project might fail to build if 3rd repository doesn't have all dependencies. 现在构建您的项目,它现在将从3rd party nexus存储库下载jar [请注意,如果3rd存储库没有所有依赖关系,则项目可能无法构建。 Once new jar is downloaded, now you place the openSAML entry back to maven settings. 下载新的jar之后,现在您将openSAML条目放回Maven设置。

Edit: 编辑:

If above option is not feasible then you can set ordering of repositories in such a manner that it checks in 3rd party repository first and then in other repositories. 如果上述选项不可行,则可以按以下方式设置存储库顺序:首先检查第3方存储库,然后再检查其他存储库。 This would mean that it will go to other repositories only if jar is not available in 3rd party. 这意味着只有在第3方中没有jar的情况下,它才会转到其他存储库。 Now the order in whichmaven checks repositories is the order in which they are written in settings.xml. 现在,maven检查存储库的顺序就是在settings.xml中写入存储库的顺序。 Check this post: How to set order of repositories in Maven settings.xml This solution is scalable as you can simply share this settings.xml across the team and you are done. 检查这篇文章: 如何在Maven settings.xml中设置存储库的顺序此解决方案是可扩展的,因为您可以在团队中简单地共享此settings.xml即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM