简体   繁体   English

mvn包忽略pom.xml中的存储库

[英]mvn package ignoring repository in pom.xml

We cannot get a project to pull from a remote repository using mvn package. 我们无法使用mvn软件包从远程存储库中提取项目。 In maven installed folder, config/settings.xml we declare our internal central repo: 在maven安装的文件夹config / settings.xml中,我们声明内部中央存储库:

<mirrors>
  <mirror>
    <id>advnexus</id>
    <mirrorOf>*</mirrorOf>
    <url>http://internalserver/nexus/content/groups/public</url>
  </mirror>
</mirrors>

This works for all of the jar files hosted at this repo. 这适用于此仓库中托管的所有jar文件。 But we have some additional jar files we pushed to a server under our control and running Sonatype Nexus. 但是,我们还有一些其他的jar文件,我们将其推送到我们控制之下的服务器上并运行Sonatype Nexus。 So in the project's pom.xml, we setup our remote repo as: 因此,在项目的pom.xml中,我们将远程仓库设置为:

<repositories>
  <repository>
    <id>companynamenexus</id>
    <name>Company Name Project Repo</name>
    <url>http://nexus.companyname.com:8081/repository/project-name</url>
    <layout>default</layout>
    <spanshots>
      <enabled>false</enabled>
    </spanshots>
  </repository>
</repositories>

When I run the build, it pulls any needed jar files from the main repo, but simply times out trying to pull the jar files that don't exist on this repo vs. using the repository in the pom.xml. 当我运行构建时,它会从主存储库中提取所有需要的jar文件,但是与使用pom.xml中的存储库相比,尝试提取该存储库中不存在的jar文件只是超时。

Note that in the settings.xml mirror section, I tried changing the <mirrorOf> to be central vs. *, but this just caused additional errors. 请注意,在settings.xml镜像部分中,我尝试将<mirrorOf>更改为与*相对的中央,但这只会导致其他错误。

I have also tried setting up this repo as a secondary mirror in the settings.xml, tried commenting out the mirror in the settings.xml and place it as an additional repository in the pom.xml, all without finding the right combination. 我也曾尝试在settings.xml中将此回购设置为辅助镜像,尝试在settings.xml中注释掉该镜像并将其作为pom.xml中的其他存储库,所有这些都没有找到正确的组合。 Seems like a simple problem, but the answer is eluding us. 似乎是一个简单的问题,但是答案却使我们难以理解。

Best solution: Don't try to access two different internal Nexus, but set up a repository group in one of the Nexus that contains all other repositories (may they be hosted or proxy, internal or external). 最佳解决方案:不要尝试访问两个不同的内部Nexus,而应在Nexus之一中设置一个存储库组,其中包含所有其他存储库(可以是托管的,也可以是内部或外部的代理)。 Then you can simply set a mirror entry on that repository group and you are fine. 然后,您只需在该存储库组上设置一个镜像条目就可以了。

Second best solution: Change your mirror entry to <mirrorOf>*,!companynamenexus</mirrorOf> and define the additional repository in the <repositories> section of your settings.xml . 第二好的解决方案:将镜像条目更改为<mirrorOf>*,!companynamenexus</mirrorOf>然后在settings.xml<repositories>部分中定义其他存储<repositories>

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

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