eclipse中使用maven插件的有关问题:Updating index central|http://repo1.maven.org/maven2

本文介绍了解决Eclipse中Maven插件因单位网络限制导致无法下载Maven索引文件的问题。通过手动下载索引文件并配置本地Apache Tomcat服务器,最终实现Maven依赖项正常添加。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 选项去除。

root@Ubuntu:/home/rt/chisel-examples/hello-world# sbt clean update [info] welcome to sbt 1.10.11 (Ubuntu Java 21.0.6) [info] loading project definition from /home/rt/chisel-examples/hello-world/project [info] loading settings for project hello-world from build.sbt... [info] set current project to hello-world (in build file:/home/rt/chisel-examples/hello-world/) [success] Total time: 0 s, completed 2025年3月26日 17:08:13 [info] Updating hello-world_2.12 [info] Resolved hello-world_2.12 dependencies [warn] [warn] Note: Unresolved dependencies path: [error] sbt.librarymanagement.ResolveException: Error downloading edu.berkeley.cs:chisel3-plugin_2.12.18:3.5.3 [error] Not found [error] Not found [error] not found: /root/.ivy2/localedu.berkeley.cs/chisel3-plugin_2.12.18/3.5.3/ivys/ivy.xml [error] not found: https://repo1.maven.org/maven2/edu/berkeley/cs/chisel3-plugin_2.12.18/3.5.3/chisel3-plugin_2.12.18-3.5.3.pom [error] at lmcoursier.CoursierDependencyResolution.unresolvedWarningOrThrow(CoursierDependencyResolution.scala:347) [error] at lmcoursier.CoursierDependencyResolution.$anonfun$update$39(CoursierDependencyResolution.scala:316) [error] at scala.util.Either$LeftProjection.map(Either.scala:573) [error] at lmcoursier.CoursierDependencyResolution.update(CoursierDependencyResolution.scala:316) [error] at sbt.librarymanagement.DependencyResolution.update(DependencyResolution.scala:60) [error] at sbt.internal.LibraryManagement$.resolve$1(LibraryManagement.scala:60) [error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$12(LibraryManagement.scala:142) [error] at sbt.util.Tracked$.$anonfun$lastOutput$1(Tracked.scala:74) [error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11(LibraryManagement.scala:144) [error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11$adapted(LibraryManagement.scala:131) [error] at sbt.util.Tracked$.$anonfun$inputChangedW$1(Tracked.scala:220 [error] at sbt.internal.LibraryManagement$.cachedUpdate(
03-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值