最近碰到这个问题,一直在整理maven的jar包问题,最后是发现很多jar包现在的过程中可能没有下完就被关闭,或者下载失败,就会出现很多的*.lastUpdated文件,这些文件使得系统认为某些jar包没有倍下载成功,因此出现了不可是别的现象。
错误:
1. The type org.springframework.context.ConfigurableApplicationContext cannot be resolved.
2. Could not calculate build plan: Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from http://repo1.maven.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:pom:2.7.1 from/to central (http://repo1.maven.org/maven2): Access denied to http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.7.1/maven-surefire-plugin-2.7.1.pom. Error code 407, Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied. )log4j-test01UnknownMaven Problem
这两个错误都会有可能是lastupdated的问题引起。
解决方法1:
1.找到maven库目录,进入:~\.m2\repository\org\apache\maven\plugins\maven-surefire-plugin\2.7.1
2.若2.7.1目录下只有,"maven-surefire-plugin-2.7.1.pom.lastUpdated" 则需要到http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.7.1/,把里面的文件下载下来放到2.7.1
3.删除2.7.1下的maven-surefire-plugin-2.7.1.pom.lastUpdated文件。(重要)
4.项目右键-->maven-->Update Dependencies
删除所有的lastupdated文件方法:
项目使用maven管理jar包,很容易因为各种原因(网速慢、断网)导致jar包下载不下来,出现很多.lastUpdated文件。这些文件一个一个删除太麻烦。下面是全部删除的方法
windows系统
cd %userprofile%\.m2\repository for /r %i in (*.lastUpdated) do del %i
linux系统
find /app/maven/localRepository -name "*.lastUpdated" -exec grep -q "Could not transfer" {} \; -print -exec rm {} \;
find /app/mujup/maven/localRepository -name "*.lastUpdated" -exec grep -q "Could not transfer" {} \; -print -exec rm {} \;
最后clean后如果还有叹号或者错误,就maven-update project后即可解决。