Maven 报:Could not find artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3

前些时候我学习Maven,我遇到了以下两个错误(该死的这两个错误,让我浪费了四天时间):

1、Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories.
Could not resolve artifact
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (D:\m2\repository)
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (D:\m2\repository)

(这个错误是在新建项目的时候报的)

2、Could not calculate build plan: Could not find artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3 in jboss-public-repository-group (http://repository.jboss.org/nexus/content/groups/public)AsamMilkTea5 未知Maven Problem(这个错误是在构建的时候报出的)


以上报错的原因是:在settings.xml 文件中 mirrors出了问题(Maven 2 Mirror的陷阱)。以前我是多个mirror  后来改为用一个mirror

<mirrors> 

     <mirror> 

         <id>ibiblio.org</id> 
        <name>ibiblio Mirror of http://repo1.maven.org/maven2/</name> 
        <url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url> 
        <mirrorOf>central</mirrorOf> 
     </mirror> 

</mirrors>

其它不要,就只要这个,就解决以上问题。

感谢welkin.hu,看了他的"Maven 2 Mirror的陷阱"这篇博文,是我解决这个问题的启发点。

Maven 2 Mirror的陷阱 (http://welkinhu.blog.51cto.com/447606/107230

Maven 2的安装和使用虽然不是一点即用,但也不是很复杂。然而,这两天我新装Maven,刚刚过了mvn -version,尝试create maven project就出问题了。问题详情如下。
D:\mavenSample>mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app 
[INFO] Scanning for projects... 
[INFO] Searching repository for plugin with prefix: 'archetype'. 
[INFO] org.apache.maven.plugins: checking for updates from central 
[INFO] org.codehaus.mojo: checking for updates from central 
[INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for updates from central 
[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------ 
[INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found 
[INFO] ------------------------------------------------------------------------ 
[INFO] For more information, run Maven with the -e switch 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 3 seconds 
[INFO] Finished at: Wed Mar 19 14:26:49 CST 2008 
[INFO] Final Memory: 1M/2M 
[INFO] ------------------------------------------------------------------------
开始以为是internet 代理设置有问题。网上也有帖子这么说。可是换到ADSL后,不用代理了,问题仍然存在。
几经周折后发现,原因在于我画蛇添足多加了几个镜像,其中有的镜像没有同步更新maven库。经过测试,如下maven 镜像工作正常:
<mirror> 
<id>ibiblio.org</id> 
<name>ibiblio Mirror of  [url]http://repo1.maven.org/maven2/[/url]</name> 
<mirrorOf>central</mirrorOf> 
<!-- United States, North Carolina --> 
</mirror> 
<mirror> 
<id>redv.com</id> 
<mirrorOf>central</mirrorOf> 
<!-- Shanghai, China , Very fast--> 
</mirror> 
<mirror> 
<id>dotsrc.org</id> 
<mirrorOf>central</mirrorOf> 
<!-- Denmark --> 
</mirror> 
<mirror> 
<id>sunsite.dk</id> 
<mirrorOf>central</mirrorOf> 
<!-- Denmark --> 
</mirror> 
<mirror> 
<id>skynet.be</id> 
<mirrorOf>central</mirrorOf> 
<!-- Belgium --> 
</mirror> 
<mirror> 
<id>cica.es</id> 
<mirrorOf>central</mirrorOf> 
<!-- Spain, Sevilla --> 
</mirror> 
<!-- these just point to ibiblio.org --> 
<mirror> 
<id>ibiblio.net</id> 
<name>ibiblio.net Mirror of  [url]http://repo1.maven.org/maven2/[/url]</name> 
<mirrorOf>central</mirrorOf> 
<!-- United States, North Carolina Fast--> 
</mirror>
而下面的Maven镜像都有问题。
<mirror> 
<id>planetmirror</id> 
<name>Australian Mirror of  [url]http://repo1.maven.org/maven2/</name[/url]
<mirrorOf>central</mirrorOf> 
</mirror> 
<mirror> 
<id>lsu.edu</id> 
<mirrorOf>central</mirrorOf> 
<!-- United States, Louisiana --> 
</mirror> 
<mirror> 
<id>sateh.com</id> 
<mirrorOf>central</mirrorOf> 
<!-- The Netherlands, Amsterdam --> 
</mirror> 
<mirror> 
<id>ggi-project.org</id> 
<mirrorOf>central</mirrorOf> 
<!-- The Netherlands, Amsterdam --> 
</mirror>

本文出自 “威尔金的IT博客,51CTO” 博客,请务必保留此出处http://welkinhu.blog.51cto.com/447606/107230



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值