Maven 提升下載jar速度方法: (每秒1MB左右)

我們都知道,當我們在pom文件裏面添加一個新的依賴時,maven發現本地倉庫裏面沒有該jar包就會到中央倉庫去下載,但是中央倉庫在國外,下載速度緩慢的令人髮指。我們可以在setting.xml(eg:G:\maven\apache-maven-3.0.4\conf\setting.xml)文件裏面配置一個國內鏡像

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

修改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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章