Maven为什么要配置镜像仓库

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镜像(阿里云镜像)

 

 
  1. <mirrors>

  2. <!-- mirror

  3. | Specifies a repository mirror site to use instead of a given repository. The repository that

  4. | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used

  5. | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.

  6. |

  7. -->

 
  1. <mirror>

  2. <id>alimaven</id>

  3. <name>aliyun maven</name>

  4. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>

  5. <mirrorOf>central</mirrorOf>

  6. </mirror>

  7. </mirrors>

  

国内其他镜像文件(值得收藏)

 
  1. <mirror>

  2. <id>alimaven</id>

  3. <name>aliyun maven</name>

  4. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>

  5. <mirrorOf>central</mirrorOf>

  6. </mirror>

  7. <mirror>

  8. <id>alimaven</id>

  9. <mirrorOf>central</mirrorOf>

  10. <name>aliyun maven</name>

  11. <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>

  12. </mirror>

  13.  
  14. <mirror>

  15. <id>ibiblio</id>

  16. <mirrorOf>central</mirrorOf>

  17. <name>Human Readable Name for this Mirror.</name>

  18. <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>

  19. </mirror>

  20. <mirror>

  21. <id>jboss-public-repository-group</id>

  22. <mirrorOf>central</mirrorOf>

  23. <name>JBoss Public Repository Group</name>

  24. <url>http://repository.jboss.org/nexus/content/groups/public</url>

  25. </mirror>

  26.  
  27. <mirror>

  28. <id>central</id>

  29. <name>Maven Repository Switchboard</name>

  30. <url>http://repo1.maven.org/maven2/</url>

  31. <mirrorOf>central</mirrorOf>

  32. </mirror>

  33. <mirror>

  34. <id>repo2</id>

  35. <mirrorOf>central</mirrorOf>

  36. <name>Human Readable Name for this Mirror.</name>

  37. <url>http://repo2.maven.org/maven2/</url>

  38. </mirror>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值