最近在使用maven添加依赖的时候,动不动idea就会从Updating [central] https://repo./maven2开始下载1.23G的文件。即使在maven setting.xml中配置了阿里云的镜像。
原因是所有自定义pom.xml都是继承自super pom:
<repositories><repository><id>central</id><name>Central Repository</name><url>http://repo./maven2</url><layout>default</layout><snapshots><enabled>false</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>central</id><name>Central Repository</name><url>http://repo./maven2</url><layout>default</layout><snapshots><enabled>false</enabled></snapshots><releases><updatePolicy>never</updatePolicy></releases></pluginRepository></pluginRepositories>
因此当maven加载依赖的时候,总是会优先去中央仓库下载,
解决办法,在项目pom.xml中添加如下配置:
<repositories><repository><id>central</id><url>http://host:port/content/groups/public</url></repository></repositories><pluginRepositories><pluginRepository><id>central</id><url>http://host:port/content/groups/public</url></pluginRepository></pluginRepositories>