maven的setting配置问题
最近在学习maven的settings.xml配置时遇到了一些不理解的问题
仓库的搜索优先级。所了解到的是 本地仓库 -> 私服仓库 -> 线上的中央仓库,实际尝试的过程中,我将mirrors镜像注释掉,在profile中配置了几个阿里云仓库,实际下载的时候发现还是走的repo.maven.apache.org/maven2,也就是中央仓库,为什么没有先从私服中查找?
中央仓库的覆盖。相关博客说,仓库的
<id>central</id>
就会覆盖默认的中央仓库,如上所述,可知并没有被覆盖。
这两个问题我尝试了好多次都没有弄明白,另外假如中央仓库可以覆盖的话,直接覆盖不就好了,何必还要配置镜像呢?求解惑! 具体配置文件如下<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd"> <localRepository>F:/MavenRepository</localRepository> <pluginGroups> </pluginGroups> <proxies> </proxies> <servers> </servers> <mirrors> <!-- <mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> --> </mirrors> <profiles> <profile> <id>aLiCentral</id> <repositories> <repository> <id>central</id> <url>http://maven.aliyun.com/nexus/content/groups/public</url> <!-- <url>https://maven.aliyun.com/repository/central</url> --> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profile> <id>spring</id> <repositories> <repository> <id>spring</id> <url>https://maven.aliyun.com/repository/spring</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profile> <id>spring-plugin</id> <repositories> <repository> <id>spring-plugin</id> <url>https://maven.aliyun.com/repository/spring-plugin</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profile> <id>jdk-1.8</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.8</jdk> </activation> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> </properties> </profile> </profiles> <activeProfiles> <activeProfile>aLiCentral</activeProfile> <activeProfile>spring</activeProfile> <activeProfile>spring-plugin</activeProfile> </activeProfiles> </settings>