1

I have to use two mirrors. In .m2/settings I have

<mirrors>    
    <mirror>
      <id>nexus_xyz</id>
      <mirrorOf>*</mirrorOf>
      <url>https://../</url>
    </mirror>
    <mirror>
        <id>nexus_wso2</id>
        <mirrorOf>*</mirrorOf>
        <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
    </mirror>
</mirrors>

Then in the pom.xml of my project I don't know how to say to download something from the first mirror and something from the second mirror. Thanks

ayasha
  • 1,221
  • 5
  • 27
  • 46
  • 1
    Do you need to this to be able to download from both repo's at the same time? Or do you want to have some kind of failover if one mirror goes down, that Maven would automatically use the other one? – Wim Deblauwe Nov 15 '19 at 17:16

2 Answers2

0

If the package isn't in the first mirror, it should fallback to the second one.

In Maven, it's not possible to tell it "download this dependency from this mirror, or repository".

carlspring
  • 31,231
  • 29
  • 115
  • 197
0

The bad news: You cannot determine for different dependencies where they should be downloaded from.

But the good news: You don't need such a thing. Mirroring usually makes only sense if you want to send (nearly) every request to the same repository. You usually do this if you have a company Nexus/Artifactory and use it to proxy all external repositories you need. If you don't have a company Nexus/Artifactory, you should list the repositories you need unter the <repositories> tag in the settings.xml. In this case, you don't define a mirror, or you only mirror all requests that you do not handle otherwise (by setting <mirrorOf> to something like *,!rep1,!rep2). Maven will then go through all the defined repositories until it finds the required artifact.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142