maven+eclipse:Failure to transfer

配置好了maven环境,然后在eclipse中创建maven项目,添加依赖:

<dependency>
  <groupId>commons-logging</groupId>
  <artifactId>commons-logging</artifactId>
  <version>1.1.1</version>
 </dependency>

pom文件报错:

Failure to transfer commons-logging:commons-logging:jar:1.1.1 from https://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 commons-logging:commons-logging:jar:1.1.1 from/
 to central (https://repo.maven.apache.org/maven2): The operation was cancelled. org.eclipse.aether.transfer.ArtifactTransferException: Failure to transfer commons-
 logging:commons-logging:jar:1.1.1 from https://repo.maven.apache.org/maven2.........

问度娘了半天,没找到解决办法,最后看到有个人说common包是maven类库里的基本包,一开始就下载下来的,我就去看了下,发现本地maven类库中确实已经有了common-logging目录,在其中找到1.1.1版本的目录,发现commons-logging-1.1.1.jar.lastUpdated,正常jar包后面有个.lastUpdated后缀,我从官网下了个commons-logging-1.1.1.jar,替换了commons-logging-1.1.1.jar.lastUpdated,然后在eclipse中,选中项目-右击-maven-update project,ok 报错消失。

以后再遇到类似问题,先查看本地类库中有没有.lastUpdated后缀文件,记录一下,以后可以提醒自己。

原文地址:https://www.cnblogs.com/xuyy/p/4672908.html