使用maven時出現failure to transfer錯誤,下載jar慢

在eclipse裏使用maven,連接nexus私服。


添加依賴之後,總是報添加的依賴jar文件找不到,但是在nexus的庫裏面能找到這個依賴的jar文件,但是在本地的maven庫裏面找不到,於是我將本地庫裏面這個依賴對應的文件夾刪掉,然後在eclipse裏面執行update dependencies。成功解決問題!


右鍵單擊項目->maven->update dependencies。


引起的原因是由於本地庫從nexus中請求jar文件,如果私服中不存在則取網上下載,如果網速過慢,下載時間超過了maven設置的時間限制就會報該錯誤。

加入阿里雲資源,速度會快很多

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

  </mirrors>

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