zl程序教程

您现在的位置是:首页 >  后端

当前栏目

解决eclipse安装maven的问题:Unable to update index for central|http://repo1.maven.org/maven2详解编程语言

Maven安装eclipse编程语言HTTP 问题 详解 解决
2023-06-13 09:20:39 时间

问题产生如下:
因为单位使用了过滤,访问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 的!呵呵!我直接就把这个选上了!

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/13381.html

cjavawindowsxml