maven初使用遇到的一些问题-新建maven项目时pom.xml报的缺包错误

         其实,也不是才接触maven,只是以前配置的时候因为很多的东西别人都准备好了的,没出现这么多问题,这是第一次在自己的电脑上配置,刚创建一个maven项目,都还没做什么的时候,pom.xml就报错了,鼠标移到红叉上,得到错误如下:

1.Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:jar:2.10 from http://repo.maven.apache.org/maven2 

 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or 

 updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:jar:2.10 

 from/to central (http://repo.maven.apache.org/maven2): No response received after 60000

     意思就是说在maven的仓库里面没有找到这个maven-surefire-plugin:jar这个包,没有将这个插件下载下来,打开maven的本地库...\repository\org\apache\maven\plugins\maven-surefire-plugin\2.10会发现:里面只有一个maven-surefire-plugin-2.10.pom.lastUpdated,而没有maven-surefire-plugin-2.10.jar

解决方法: 

1.删除maven-surefire-plugin-2.7.1.pom.lastUpdated文件

2.右键点击project -> Maven - Update MAVEN Project

更新的时候要勾上Force Update of Snapshot/Releases. 

     好,这个问题是没有了,但是,接下来又来了个:

2.Failure to transfer org.apache.maven:maven-settings:pom:2.0.6 from http://repo.maven.apache.org/maven2 was cached 

 in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are 

 forced. Original error: Could not transfer artifact org.apache.maven:maven-settings:pom:2.0.6 from/to central (http://

 repo.maven.apache.org/maven2): No response received after 60000

     那么久照葫芦画瓢呗,进入到本地仓库的...\repository\org\apache\maven-settings\2.0.0.6里,删除掉里面以sha1结尾的jar包,更新maven项目。

    同样,再遇到类似仓库里缺少jar包或插件之类的问题,都可以这么解决,但是如果仓库里面是真没有jar包的话,需要去别的地方下载这个jar包,可以去阿里云下载。

还有在手动配置pom.xml中的编译插件时,报:

3.Error resolving version for plugin 'org.apache.maven.plugins:maven-compile-plugin' from the repositories [local (C:\Users\liuli

 \.m2\repository), central (http://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository

检查了半天,网上也找了许多方法,结果最后发现是将artifactId写成了maven-compile-plugin,呐,真的是粗心浪费精力。希望各位童鞋多多小心。

猜你喜欢

转载自2540611109.iteye.com/blog/2403854