问题
I have setup 'Artifactory' as intranet maven repository. I have question related to fail-over.
Project POM
<repositories>
<repository>
<id>central</id>
<url>http://mvn.mycompany.com:8081/artifactory/libs-release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://mvn.mycompany.com:8081/artifactory/libs-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://mvn.mycompany.com:8081/artifactory/plugins-release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>http://mvn.mycompany.com:8081/artifactory/plugins-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
QUESTION: Is it possible to use fail-over repository? meaning.. if my intranet repository is down, then maven build should automatically use some other location or directly from maven central??
回答1:
I am not sure why you expect your repository to be down, but falling back to maven central is a really bad idea. You loose all the benefits of using corporate repository, and don't even know about it, because there is no way to determine where your build took dependencies from.
If you are worried about the availability of your repository, you should establish HA environment with number of servers, replicated and backed up one by another.
If you are switching the environments and once you're in different environment the binary repository from the other intranet is not accessible anymore, you need to switch working with binary repository which is available in the new environment by using different profile, which will include different server urls (or maybe just a proxy to access the original server).
Anyhow - shade the maven central with your binary repository and don't use it as a backup.
回答2:
If the artifacts cannot be found in the list of <repositories/>
, Maven will automatically attempt to fallback to Maven Central.
来源:https://stackoverflow.com/questions/17688254/maven-intranet-repository-fail-over-redirect