maven在線自動更新太慢怎么辦?


使用IDEA和Eclipse開發maven項目時,maven在添加一項新的依賴時,如果發現本地倉庫沒有,就會向位於國外服務器的中央倉庫下載。如果所處網絡沒有翻牆,下載速度會慢到你想原地爆炸。

這個時候奉勸你早點給maven配置個國內鏡像。配置方法很簡單,修改setting.xml(eg:D:\data\maven\apache-maven-3.2.3\conf)文件,配置國內鏡像(例如阿里雲鏡像),配置代碼如下:

<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://repo.maven.apache.org/maven2</url>
    <mirrorOf>central</mirrorOf>
  </mirror>

</mirrors>

 

配置完保存,重啟你的IDEA/eclipse,更新maven,會發現速度快的飛起,是不是覺得幸福來的有點突然?


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM