Maven 2种异常解决方案: Failure to transfer org.apache.maven 和 Project build error: Non-resolvable parent POM for resolution will not be reattempted until the update interval of central has elapsed or upd
最近在学习springboot,从网上找了一些demo工程在本地练习,连续两次在保存pom.xml文件时出现了maven异常,导致相关依赖的jar没有下载到本地maven仓库,而且工程编译不过去,相关异常信息有:
Failure to transfer org.apache.maven:maven-plugin-api:jar:2.2.1 from http://localhost:8081/nexus/content/groups/public/ 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-plugin-api:jar:2.2.1 from/to central (http://localhost:8081/nexus/content/groups/public/): Connection refused: connect
或者是这样的:
Project build error: Non-resolvable parent POM for com.autogeneral:spring-boot-hello:0.0.1-SNAPSHOT: Failure to transfer org.springframework.boot:spring-boot-starter-
parent:pom:1.4.1.RELEASE from http://localhost:8081/nexus/content/groups/public/ 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.springframework.boot:spring-boot-starter-parent:pom:1.4.1.RELEASE
from/to central (http://localhost:8081/nexus/content/groups/public/): Connection refused: connect and 'parent.relativePath' points at wrong local POM
看了异常信息发现原来是由于自己在本地用Nexus搭建了Maven私服,而且私服没有启动,这时更新pom.xml文件,maven更新下载jar包需要去连接私服,但是连接不上所以报错。
把本地私服启动后,再去通过eclipse的maven插件去更新项目依赖,发现问题依旧!这就很痛苦了,看了maven不够智能啊!好在有万能的互联网以及广大的热心群众,终于找到了解决方案,参考的网页:https://zhidao.baidu.com/question/2202315838117162828.html 这个网页中提到了 XXX.lastUpdated文件,这个给了我启发,再一次去看上面的异常信息,根据异常信息中提示的出错jar包,去本地maven仓库中找到jar包的目录,
然后删除目录下的 XXX.lastUpdated文件,这时再去更新项目依赖,发现仍然报错,但是令人欣慰的是报错信息发生了变化,提示另外一个jar包异常,依旧按照上面的方法去找到目录,删除目录下的XXX.lastUpdated文件。如此反复了多次,直到把所有存在问题的jar包都解决了,最终maven不再报错,项目编译通过。
第二次遇到这种问题时不再这么辛苦的去逐个删.lastUpdated文件了,而是在本地maven仓库路径下搜索*.lastUpdated文件,然后将搜出来的全删掉,一把就搞定了!看了这种文件是个不详之物啊。
我的问题是由于本地私服没启动导致的,后面嫌麻烦(自己每次都忘了启私服),干脆在maven配置文件中取消了私服。大家在使用maven过程中如果因为网络连接等问题导致jar包更新出现类似上面的异常,可以参照我的经历,删除所有*.lastUpdated文件试试。