JAVA MyEclipse(3)---解决MyEclipse安装maven的问题:Unable to update index for central

来源:互联网 发布:游族网络2017定增 编辑:程序博客网 时间:2024/05/21 05:58

问题产生如下:
因为单位使用了过滤,访问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.propertieshttp://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><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>nexus-aliyun</id>        <mirrorOf>*</mirrorOf>        <name>Nexus aliyun</name>        <url>http://maven.aliyun.com/nexus/content/groups/public</url>    </mirror>  </mirrors>

方法三:禁用
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 的!呵呵!我直接就把这个选上了!

—————————————————————————————————————————————————–

java架构师项目实战,高并发集群分布式,大数据高可用视频教程,共760G

下载地址:

https://item.taobao.com/item.htm?id=555888526201

01.高级架构师四十二个阶段高
02.Java高级系统培训架构课程148课时
03.Java高级互联网架构师课程
04.Java互联网架构Netty、Nio、Mina等-视频教程
05.Java高级架构设计2016整理-视频教程
06.架构师基础、高级片
07.Java架构师必修linux运维系列课程
08.Java高级系统培训架构课程116课时
+
hadoop系列教程,java设计模式与数据结构, Spring Cloud微服务, SpringBoot入门
—————————————————————————————————————————————————–

阅读全文
0 0
原创粉丝点击