一、实现功能
因为不同地方网速不同,导致常用的maven依赖包无法下载,而报错:
所以,必备的是在maven的setting.xml中多配置几个镜像源。从而可以实现,采用最快的下载。当然,maven项目只会采用最上面的一个镜像源。
二、镜像源
1.阿里镜像源
<!-- 阿里仓库-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
2.官网镜像源https://mvnrepository.com/
备注:这个镜像源解决了近期无法使用阿里镜像源下载jar包的问题,很好用,十分推荐!
<mirror>
<id>mvnrepository</id>
<mirrorOf>mvnrepository</mirrorOf>
<url>http://mvnrepository.com/</url>
</mirror>
三、总结
多存储几套,非常有用已被不时之需。但是,因为其他镜像源没有解决我这次遇到的问题,所以,在此只是记录最有用的两个镜像源。
(附录)采用完整的镜像链接
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>mvnrepository</id>
<mirrorOf>mvnrepository</mirrorOf>
<url>http://mvnrepository.com/</url>
</mirror>
<!--自定义添加-->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
<!--默认的中央仓库-->
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
<!-- 阿里仓库-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<!-- maven仓库官方-->
<mirror>
<id>nexus</id>
<name>internal nexus repository</name>
<!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
<url>http://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>