简单介绍setting.xml中 mirrorOf 的配置对构件下载的影响
说明:安装的maven环境都会继承超级POM,可以在$M2_HOME/lib/maven-model-builder-3.3.9.jar 看到默认继承了中央仓库:
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories
jar包路径:maven-model-builder-3.3.9.jar\org\apache\maven\model
一般的conf/setting.xml中的镜像配置为:
<settings>
...
<mirrors>
<mirror>
<id>other-mirror</id>
<name>Other Mirror Repository</name>
<url>https://other-mirror.repo.other-company.com/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
...
</settings>
其中<mirrorOf>的值为central,表示该配置为中央仓库,与上文的repository id一致,如果配置了私服,则可以修改mirrorof的值,这里简单介绍一下mirrorOf中值的配置
- <mirrorOf>*</mirrorOf> 匹配所有的远程仓库
- <mirrorOf>external:*</mirrorOf>匹配所有远程仓库,使用localhost的除外,使用file://协议的除外。也就是说,匹配所有不在本机上的远程仓库
- <mirrorOf>repo1,repo1</mirrorOf> 匹配仓库repo1和repo2,使用逗号分隔多个远程仓库
- <mirrorOf>*,!repo3</mirrorOf> 匹配所有远程仓库,repo3除外,使用感叹号将仓库从匹配中排除
注意:id在setting.xml文件中唯一, mirrorOf不能和任何mirror的id一致
,