Java自学者论坛

 找回密码
 立即注册

手机号码,快捷登录

恭喜Java自学者论坛(https://www.javazxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,会员资料板块,购买链接:点击进入购买VIP会员

JAVA高级面试进阶训练营视频教程

Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程Go语言视频零基础入门到精通Java架构师3期(课件+源码)
Java开发全终端实战租房项目视频教程SpringBoot2.X入门到高级使用教程大数据培训第六期全套视频教程深度学习(CNN RNN GAN)算法原理Java亿级流量电商系统视频教程
互联网架构师视频教程年薪50万Spark2.0从入门到精通年薪50万!人工智能学习路线教程年薪50万大数据入门到精通学习路线年薪50万机器学习入门到精通教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程MySQL入门到精通教程
查看: 5363|回复: 0

Maven - 解决Maven下载依赖包速度慢问题

[复制链接]
  • TA的每日心情
    奋斗
    9 小时前
  • 签到天数: 793 天

    [LV.10]以坛为家III

    2049

    主题

    2107

    帖子

    72万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    723458
    发表于 2021-4-21 10:07:14 | 显示全部楼层 |阅读模式

    通常我们会因为下载jar包速度缓慢而苦恼,这十分影响开发效率,以及程序员的心情,在IDE下载jar时,无法对IDE做任何动作,只能大眼对小眼。

    下载jar速度慢究其原因就是因为很多资源都是国外的,我们下载一个小文件几乎就跨越了一个太平洋那么远,那么有什么方法可以让下载速度变快呢?

     

    其实方法很简单:maven是支持镜像的,我们可以在${maven_home}的conf目录下的setting.xml文件中找到<mirrors></mirrors>标签

    <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>  
         -->  
          
      </mirrors>  

    在这个标签中加入国内的镜像即可

    这里我推荐maven阿里云中央仓库

    <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>  
     <mirrorOf>central</mirrorOf>  
     <name>aliyun maven</name>  
     <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>  
    </mirror> 

     下面是一些常用的maven国内镜像

    <mirror>  
          <id>CN</id>    
          <name>OSChina Central</name>                                                                                                                           
          <url>http://maven.oschina.net/content/groups/public/</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>      
        <mirror>      
              <id>net-cn</id>      
              <mirrorOf>central</mirrorOf>      
              <name>Human Readable Name for this Mirror.</name>      
              <url>http://maven.net.cn/content/groups/public/</url>       
        </mirror>      
        <mirror>      
              <id>ui</id>      
              <mirrorOf>central</mirrorOf>      
              <name>Human Readable Name for this Mirror.</name>      
             <url>http://uk.maven.org/maven2/</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>JBossJBPM</id>  
              <mirrorOf>central</mirrorOf>  
              <name>JBossJBPM Repository</name>  
              <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>  
        </mirror>  
             <mirror>      
              <id>antelink</id>  
              <mirrorOf>central</mirrorOf>  
              <name>antelink Repository</name>  
              <url>http://maven.antelink.com/content/repositories/central/</url>  
        </mirror>  
        <mirror>      
              <id>openkoala</id>  
              <mirrorOf>central</mirrorOf>  
              <name>openkoala Repository</name>  
              <url>http://nexus.openkoala.org/nexus/content/groups/Koala-release/</url>  
        </mirror>  
        <mirror>      
              <id>tmatesoft</id>  
              <mirrorOf>central</mirrorOf>  
              <name>tmatesoft Repository</name>  
              <url>http://maven.tmatesoft.com/content/groups/public/</url>  
        </mirror>  
        <mirror>      
              <id>mavensync</id>  
              <mirrorOf>central</mirrorOf>  
              <name>mavensync Repository</name>  
              <url>http://mavensync.zkoss.org/maven2/</url>  
        </mirror> 

     

    哎...今天够累的,签到来了1...
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|Java自学者论坛 ( 声明:本站文章及资料整理自互联网,用于Java自学者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-9-18 23:48 , Processed in 0.064298 second(s), 29 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表