maven 更新jar很慢解決辦法--配置阿里雲鏡像

我們都知道,當我們在pom文件裏面添加一個新的依賴時,maven發現本地倉庫裏面沒有該jar包就會到中央倉庫去下載,但是中央倉庫在國外,下載的速度比蝸牛還慢,

解決方法:配置國內鏡像(如阿里雲的鏡像)

修改conf/settings.xml文件,文件的具體位置可以在這裏查看,話說不如圖解

 

如果說你是第一次配置的話,可能是Bundled(Maven 3)也可能是別的,點擊右面下拉三角形也可以看到,安裝maven的路徑

修改上面路徑下的 conf/settings.xml文件

配置阿里雲鏡像代碼如下

<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>alimaven</id>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>
  </mirror>
  <mirror> 
    <id>uk</id>  
    <mirrorOf>central</mirrorOf>  
    <name>Human Readable Name for this Mirror.</name>  
    <url>http://uk.maven.org/maven2/</url> 
  </mirror>
   <mirror>
    <id>CN</id>
    <name>OSChina Central</name>
    <url>http://maven.oschina.net/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>
  </mirror>
  <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>
配置完更新一下maven所需的jar包

選擇項目--》右擊--》Maven--》Reimport

這時,你會發現你的更新速度快了一萬唄,很快就更新完成了。

注意:你配置了從哪個倉庫下載jar包之後,一定要在IDEA或者eclipse中進行配置,因爲默認會選擇從Bundled(Maven 3)等,從國外下載。

博客參考:https://blog.csdn.net/Huangjie515/article/details/53494457

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章