Java 如何解析maven存储库?
假设我的Java 如何解析maven存储库?,java,maven,maven-3,Java,Maven,Maven 3,假设我的settings.xml定义如下 <?xml version="1.0" encoding="UTF-8"?> <settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.or
settings.xml
定义如下
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://artifactory.ark.local:8080/libs-release</url>
</repository>
<repository>
<id>vmware-repo</id>
<name>VM Nexus Repo</name>
<url>http://build-squid.eng.vm.com/nexus/content/groups/repo</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://artifactory.ark.local:8080/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://artifactory.ark.local:8080/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://artifactory.ark.local:8080/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
假设在metrics
pom中添加了存储库
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
克劳德拉
https://repository.cloudera.com/artifactory/cloudera-repos/
a
中定义了依赖项,则该依赖项在两个cloudera中都存在
repo和本地nexus repo maven将如何解析存储库?
它会首先尝试从cloudera repo下载吗
一些问题,然后它将进入本地nexus回购或它将检查
仅在cloudera回购中,如果不存在,则会出现错误
没有尝试从本地nexus回购
A
,上述问题的答案是否会发生变化
作为metric
中的依赖项,或存储库不可用的其他pom中的依赖项
定义
Maven版本-3.6.3这一点已在中得到回答。只需在这里重新发布答案 答案取决于以下几点:
- 中央回购(含Aa)
- 公司回购(包含Ab)
- 阿尔法 --A
- bravo(有额外的R存储库,如您的cloudera,包含Ac) --A
- 查理 --A
- 这次建立秩序阿尔法,好极了,查理
- Alpha需要A,Aa在中央回购中下载,这是订单列表中的第一个回购
- Bravo需要A,它在本地回购协议中看到Aa并使用它
- Charlie需要A,它在本地回购协议中看到Aa并使用它
- Bravo需要一个,Ac是下载的,因为它在R回购中,这是订单列表中的第一个回购,我认为这是pom回购当时的母公司 pom的设置文件
- Alpha需要A,它在本地回购中看到Ac并使用它
- Charlie需要A,它在本地回购协议中看到Ac并使用它
- 这次建立秩序阿尔法,好极了,查理
- Alpha需要A,Aa在中央回购中下载,这是订单列表中的第一个回购,但它有一个Ab缓存
- Bravo需要一个,它发现它没有一个from R repo的缓存,所以会查找from R repo,如果R repo中的Ac较新,它会被下载 用过。在这种情况下,Aa较新,因此使用Aa
- Charlie需要A,它看到所有的回购都有A的缓存,只在本地回购中使用A,在这种情况下使用Aa
- 这次建立秩序阿尔法,好极了,查理
- Alpha需要A,Aa在中央回购中下载,这是订单列表中的第一个回购,但它有一个Ab缓存
- Bravo需要一个,它发现它没有一个from R repo的缓存,所以会查找from R repo,如果R repo中的Ac较新,它会被下载 用过。在这种情况下,Ac较新,因此使用Ac
- Charlie需要A,它看到所有的回购都有A的缓存,只在本地回购中使用A,在这种情况下使用Ac
我不知道,但我会尽量避免在POMs中定义存储库。它会检查本地m2是否存在工件,然后按照xml中定义的顺序检查项目定义的repo(cloudera)和settings.xml。根据我的经验,存储库是按字母顺序解析的,所以它将首先解析cloudera,然后解析nexus。如果要强制执行订单,请在其前面加上数字
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>