java – 多个存储库的Maven设置
作者:互联网
我在settings.xml中有以下内容
<mirrors>
<mirror>
<id>paid-jars</id>
<name>jars with license</name>
<url>http://url:8081/nexus/content/repositories/paidjars/</url>
<mirrorOf>!central</mirrorOf>
</mirror>
<mirror>
<id>Org-central</id>
<name>mirror of central</name>
<url>http://url:8081/nexus/content/repositories/central/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
在pom.xml中我有两个罐子
> apache-commons.jar(我假设从中心下载)
> licensed.jar(我假设从付费罐子下载)
但是当我运行maven clean install时,它会尝试从Org-central下载licensed.jar.
如何让它使用付费罐子下载?是否有可能首先进入Org-central,如果失败,它会尝试付费罐子?如果是这样,怎么样?我不想把repo条目放在pom.xml中
将Settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>Proxy</id>
<active>true</active>
<protocol>http</protocol>
<username>username</username>
<password>******</password>
<host>host.url</host>
<port>8080</port>
<nonProxyHosts>local.net|internal.com</nonProxyHosts>
</proxy>
</proxies>
<mirrors>
<mirror>
<id>paid-jars</id>
<name>jars with license</name>
<url>http://url:8081/nexus/content/repositories/paidjars/</url>
<mirrorOf>!central</mirrorOf>
</mirror>
<mirror>
<id>Org-central</id>
<name>mirror of central</name>
<url>http://url:8081/nexus/content/repositories/central/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>compiler</id>
<properties>
<JAVA_1_7_HOME>C:\Program Files (x86)\Java\jdk1.7.0_51\bin</JAVA_1_7_HOME>
</properties>
</profile>
</profiles>
</settings>
解决方法:
你必须设置镜像
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://internal/nexus/content/repositories/thirdparty</url>
</mirror>
<mirror>
<id>google</id>
<mirrorOf>google</mirrorOf>
<url>http://google-maven-repository.googlecode.com/svn/repository</url>
</mirror>
然后添加内部和外部回购
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<name>central</name>
<url>http://internal/nexus/content/repositories/thirdparty</url>
</repository>
<repository>
<id>google</id>
<name>google</name>
<url>http://google-maven-repository.googlecode.com/svn/repository</url>
</repository>
</repositories>
</profile>
标签:java,build,nexus,repository,maven-3 来源: https://codeday.me/bug/20191004/1851795.html