聯通網絡環境上無法訪問http://repo1.maven.org/maven2/中央庫解決,鏡像庫添加

聯通網絡環境下無法訪問http://repo1.maven.org/maven2/中央庫解決,鏡像庫添加
Maven 2的安裝和使用雖然不是一點即用,但也不是很複雜。然而,這兩天我新裝Maven,剛剛過了mvn -version,嘗試create maven project就出問題了。問題詳情如下。發現聯通寬帶屏蔽了中央庫http://repo1.maven.org/maven2/ 域名IP地址,搞不懂是怎麼想的...電信可以正常訪問。
D:\mavenSample>mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from central
[INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for updates from central
[INFO] ------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Wed Mar 19 14:26:49 CST 2008
[INFO] Final Memory: 1M/2M
[INFO] ------------------------------------
開始以爲是internet 代理設置有問題。網上也有帖子這麼說。可是換到ADSL後,不用代理了,問題仍然存在。
幾經周折後發現,原因在於自己的聯通網絡環境下無法訪問中央庫,在網上找了幾個鏡像,其中有的鏡像沒有同步更新maven庫。經過測試,如下maven 鏡像工作正常:
  <mirrors>
    <mirror>
      <id>ibiblio.org</id>
      <name>ibiblio Mirror of http://repo1.maven.org/maven2/</name>
      <url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- United States, North Carolina -->
    </mirror>
   <mirror>
      <id>cica.es</id>
      <url>http://ftp.cica.es/mirrors/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- Spain, Sevilla -->
    </mirror>
   
    <mirror>
      <id>skynet.be</id>
      <url>http://maven2.mirrors.skynet.be/pub/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- Belgium -->
    </mirror>

  </mirrors>
在setting.xml中添加上面的鏡像服務器
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章