Maven为什么要配置镜像仓库
2018年05月24日 10:27:31 豪哥是上帝 阅读数:1074
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Eye9093/article/details/80430720
为什么需要配置maven国内镜像?
1、在不配置镜像的情况下,maven默认会使用中央库.
2、maven中央库在国外,有时候访问会很慢,尤其是下载较大的依赖的时候,有时候速度会很慢,甚至会出现无法下载的情况.
3、为了解决依赖下载速度的问题,需要配置maven国内镜像
镜像配置方式和比较
1、maven镜像有两种配置,一种是在settings.xml中进行配置,第二种是在pom.xml中进行配置.
2、在settings.xml中进行配置会对所有maven工程有效,当在升级maven版本的时候,需要注意复制已经配置好的settings.xml到新的maven目录下
3、使用第一种配置pom.xml的方式只会对当前工程有效,本文建议大家使用第二种配置方式。.
配置国内maven镜像(阿里云镜像)
-
<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>alimaven</id>
-
<name>aliyun maven</name>
-
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
-
<mirrorOf>central</mirrorOf>
-
</mirror>
-
</mirrors>
国内其他镜像文件(值得收藏)
-
<mirror>
-
<id>alimaven</id>
-
<name>aliyun maven</name>
-
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
-
<mirrorOf>central</mirrorOf>
-
</mirror>
-
<mirror>
-
<id>alimaven</id>
-
<mirrorOf>central</mirrorOf>
-
<name>aliyun maven</name>
-
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
-
</mirror>
-
<mirror>
-
<id>ibiblio</id>
-
<mirrorOf>central</mirrorOf>
-
<name>Human Readable Name for this Mirror.</name>
-
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
-
</mirror>
-
<mirror>
-
<id>jboss-public-repository-group</id>
-
<mirrorOf>central</mirrorOf>
-
<name>JBoss Public Repository Group</name>
-
<url>http://repository.jboss.org/nexus/content/groups/public</url>
-
</mirror>
-
<mirror>
-
<id>central</id>
-
<name>Maven Repository Switchboard</name>
-
<url>http://repo1.maven.org/maven2/</url>
-
<mirrorOf>central</mirrorOf>
-
</mirror>
-
<mirror>
-
<id>repo2</id>
-
<mirrorOf>central</mirrorOf>
-
<name>Human Readable Name for this Mirror.</name>
-
<url>http://repo2.maven.org/maven2/</url>
-
</mirror>