maven编译下载文件失败

[size=x-large]问题描述[/size]

执行maven命令的时候报错,不能从中央仓库下载jar包回来,导致命令失败

$ mvn clean eclipse:clean eclipse:eclipse
....
Downloading: http://oss.sonatype.org/org/sonatype/oss/oss-parent/2/oss-parent-2.pom
178b downloaded (oss-parent-2.pom)
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '81ffbd1712afe8cdf138b570c0fc9934742c33c1'; remote = '<html>
<head><title>301' - RETRYING
Downloading: http://oss.sonatype.org/org/sonatype/oss/oss-parent/2/oss-parent-2.pom
178b downloaded (oss-parent-2.pom)
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '81ffbd1712afe8cdf138b570c0fc9934742c33c1'; remote = '<html>
<head><title>301' - IGNORING
[ERROR] An error occurred during dependency resolution of the following artifact:
com.ning:compress-lzf:0.6.0
Caused by: Unable to get dependency information: Unable to read the metadata file for artifact 'com.ning:compress-lzf:jar': Cannot find parent: org.sonatype.oss:oss-parent for project: com.ning:compress-lzf:bundle:0.6.0 for project com.ning:compress-lzf:bundle:0.6.0
com.ning:compress-lzf:jar:0.6.0

from the specified remote repositories:
central (http://xxx.com/mvn/repository),
snapshots (http://xxx.com/mvn/repository)

Path to dependency:
1)xxxx:xxx1:jar:2.0-SNAPSHOT
2) xxx:xxx2:jar:1.13.6
...



[size=x-large]原因分析[/size]
从错误提示可以看出,问题出在下载oss-parent-2.pom这个包失败,导致后面对com.ning:compress-lzf:jar的解析失败,进而整个build受影响失败。

原因是maven官方不再维护maven2,而maven2项目在构建过程中,有可能需要sonatype.org域名下的文件,这些文件已经被移除,导致构建失败。

除了pom文件以外,还有一些sonatype.org域名下的插件也被移除。

[size=x-large]解决方案[/size]

[list=1]
[*] copy相应文件到本地仓库
maven的设计体系里,本身就有本地仓库/中央仓库之分,只要本地仓库里存在,就不会再访问中央仓库或是官网。
找一下其它还在使用maven2的人(或者也可以[url=https://github.com/tinyhema/file-for-downlod/raw/master/sonatype.zip]到这里来下载[/url]),$M2_REPO/org/sonatype目录下的所有文件全部copy到本地仓库即可。
[*] 另一个更好的解决方案是,尽快升级maven3,^_^。
[/list]

[quote]
此外,这个问题也暴露了maven2设计中的小问题,本地仓库/中央仓库模式已经设计的很棒了,如果把所有这些org.sonatype下的文件也都纳入中央仓库体系,就能避免这个问题啦。
[/quote]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值