`
tinyhema
  • 浏览: 150412 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

maven编译下载文件失败

 
阅读更多
问题描述

执行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
...



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

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

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

解决方案

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


引用

此外,这个问题也暴露了maven2设计中的小问题,本地仓库/中央仓库模式已经设计的很棒了,如果把所有这些org.sonatype下的文件也都纳入中央仓库体系,就能避免这个问题啦。

分享到:
评论
2 楼 tinyhema 2015-01-06  
chenjianjx 写道
很好,最近搭建新环境,用到了你这里的内容。

1 楼 chenjianjx 2014-12-17  
很好,最近搭建新环境,用到了你这里的内容。

相关推荐

Global site tag (gtag.js) - Google Analytics