mvn package ignoring repository in pom.xml

user25839 :

We cannot get a project to pull from a remote repository using mvn package. In maven installed folder, config/settings.xml we declare our internal central repo:

<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. But we have some additional jar files we pushed to a server under our control and running Sonatype Nexus. So in the project's pom.xml, we setup our remote repo as:

<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.

Note that in the settings.xml mirror section, I tried changing the <mirrorOf> to be central vs. *, but this just caused additional errors.

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. Seems like a simple problem, but the answer is eluding us.

JF Meier :

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). 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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=166734&siteId=1