MAVEN配置合适镜像源(阿里、官方)提升依赖下载速度

一、实现功能

因为不同地方网速不同,导致常用的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>

 

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值