[size=x-large]问题描述[/size]
执行maven命令的时候报错,不能从中央仓库下载jar包回来,导致命令失败
[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]
执行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]