解決eclipse安裝maven的問題:Unable to update index for central|http://repo1.maven.org/maven2


問題產生如下:
因為單位使用了過濾,訪問Internet時,超過10M的內容就拒絕。
因為maven插件在初始時,需要下載Maven的index文件,這個文件比較大,有38M多,下載不成功。
所以造成使用Maven添加依賴項時(Add Dependency)時,沒有提示項目可用,並且在Console中,輸出:
Unable to update index for central|http://repo1.maven.org/maven2 。

解決方式如下:1、通過其它方式下載如下兩個文件:
http://repo1.maven.org/maven2/.index/nexus-maven-repository-index.properties
http://repo2.maven.org.s3.amazonaws.com/.index/nexus-maven-repository-index.gz

2、找一個Apache服務器,在其根據目錄下建立一個 .index 的目錄,把上述兩個文件拷貝至該目錄下。

3、編輯 c:\WINDOWS\system32\drivers\etc\hosts 文件,在文件中加入:
10.15.2.52 repo2.maven.org.s3.amazonaws.com
注:10.15.2.52 為步驟2的Apache服務器IP地址。

4、在Eclipse中,打開 Maven Repositories 面板,
在 Global Repositories --> central 項上,點右鍵,Rebuild Index 即可。

5、移除之前在 hosts 文件中添加的內容。

6、(可選)把Properties中Maven項的 Download repository index updates on starup 選項去除。

 

方法二:設置代理

copy一個settings.xml到C:/Documents and Settings/username/.m2目錄,並修改settings.xml文件,添加一個http代理:

  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>www.yourproxy.com</host>
      <port>8080</port>
    </proxy>
  </proxies>

 

方法三:禁用

1.在myeclipse3.4(我用的這個版本)里面Window => Preferences => Myeclipse Enterprise Workbench => Maven4Myeclipse => Maven=>禁用Download repository index updates on startup
2.樓上的!我用的是 myeclipse7.1 以前也是和你一樣沒有找到!后來終於找到了! 
首先你要 Window => Preferences => Myeclipse Enterprise Workbench => Maven4Myeclipse 
這個里面啟用 Enable Maven4Myeclipse features ,打上勾,要先啟用這個插件 
這樣 Window => Preferences => Myeclipse Enterprise Workbench => Maven4Myeclipse => Maven 
就有了!再選中就好了! 
其實上面還有一項 offline 的!呵呵!我直接就把這個選上了!


免責聲明!

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



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