前言
作为一个合格的springer,我们的工作不能没有maven,就像西方不能没有耶路撒冷。但是,最近我才发现我配了两年半的阿里云镜像不生效。
起因是我想使用maven引入ws.schild jave-all-deps。但是由于此文件太大,我始终下不下来,就在我一直以为是公司的网在作妖时,我突然发现download url竟然是啥https://repo.maven.apache.org/maven2巴拉巴拉。于是我怒从心中起,恶向胆边生,怒登aliyun的maven仓库发现仓库中确实是有此依赖。证实了我的配置是不生效的。
正确配置aliyun镜像
首先,是大家都熟悉的mirror环节
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
是不是网上好多教程到这里就结束了,偶的评价是只配这个等于没配,还需要搭配要去阿里云的哪个仓库这里配的是central中心仓库,可以按需配置
<profiles>
<profile>
<id>central</id>
<repositories>
<repository>
<id>central</id>
<url>https://maven.aliyun.com/repository/central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<!--只下载稳定版-->
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
最后配置完后还需要激活指定的profile
<activeProfiles>
<activeProfile>central</activeProfile>
</activeProfiles>
保存完之后使用maven下载,直接起飞🛫️!