注意不要在逗号分隔列表中的标识符或通配符周围包含额外的空格。例如,将设置为!repo1, *不会镜像任何内容,而!repo1,*将镜像除repo1之外的所有内容。
通配符在以逗号分隔的仓库标识符列表中的位置并不重要,因为通配符会推迟进一步处理,并且显式包含或排除会停止处理,从而否决任何通配符匹配(原文:The position of wildcards within a comma separated list of repository identifiers is not important as the wildcards defer to further processing and explicit includes or excludes stop the processing, overruling any wildcard match)。
当您使用高级语法并配置多个镜像时,声明顺序很重要。当Maven查找某个仓库的镜像时,它首先检查与仓库标识符完全匹配的镜像。如果没有找到直接匹配,Maven会根据上面的规则(如果有的话)选择第一个匹配的镜像声明。因此,可以通过更改settings.xml中定义的顺序来影响匹配顺序
示例:
*=所有仓库
external:*=所有不在本地主机上且不基于文件的内容。
repo,repo1 = repo 或者repo1
*,!repo1 = 除repo1的所有仓库
<settings>
...
<mirrors>
<mirror>
<id>internal-repository</id>
<name>Maven Repository Manager running on repo.mycompany.com</name>
</settings>Windows XP Windows x86 5.1.2600<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"