eclipse中使用maven插件的问题:Updating index 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 Tomcat服务器,在其根目录下建立一个 /maven2/.index 的虚拟目录(注意: 如果你使用的是windows系统, 可能无法建立.index文件夹, 必须使用DOS命令:mkdir .index),把上述两个文件拷贝至该虚拟目录指向的目录下。


3)编辑 c:\WINDOWS\system32\drivers\etc\hosts 文件,在文件中加入:
127.0.0.1 repo1.maven.org
注:127.0.0.1 为步骤2的Apache Tomcat服务器IP地址。

4)在Eclipse中,打开 Maven Repositories 面板在 Global Repositories --> central 项上,点右键,Rebuild Index 即可。

5)移除之前在 hosts 文件中添加的内容。

6)(可选)把Properties中Maven项的 Download repository index updates on starup 选项去除。

猜你喜欢

转载自frank1998819.iteye.com/blog/1946536