开发者

How do I configure maven to access maven central if nexus server is down?

开发者 https://www.devze.com 2023-03-16 19:26 出处:网络
I would like to setup my build such that it automatically attempts to download an artifact from maven central iff our nexus server is unreachable.I have the following in settings.xml and I\'m not sure

I would like to setup my build such that it automatically attempts to download an artifact from maven central iff our nexus server is unreachable. I have the following in settings.xml and I'm not sure how to change it (if even possible).

<profiles>
<profile>
 <id>nexus</id>
 <!--Enable snapshots for the built in central repo to direct -->
 <!--all requests to nexus via the mirror -->
 <repositories>
   <repository>
     <id>central</id>
     <url>http://mynexus</url>
     <releases><enabled>true</enabled></releases>
     <snapshots><enabled>true</enabled></snapshots>
   </repository>
 </repositories>
 <pluginRepositories>
   <pluginRepository>
     <id>central</id>
     <url>http://mynexus</url>
     <releases><enabled>true</enabled></releases>
     <snapshots><enabled>true</enabled></snapshots>
   </pluginRepository>
 </pluginRepositories>
</profile>
</profiles>

<activeProfiles>
   <activeProfile>nexus</activePro开发者_StackOverflowfile>
</activeProfiles>


In order to use a repository manager (Nexus included) you need to have a mirrorOf * element defined that will intercept all the repository urls and send them to Nexus for resolution. In Maven2 and 3, the mirrorOf element is not able to be configured in a profile. This means there is no easy way to flip back and forth without changing your settings.

You would need to comment out the mirrors section and then deactivate the Nexus profile to have Maven revert back to standard behavior.

Fortunately though Nexus is very stable and it should never go down.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号