Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central

maven部 Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central

问题:

maven安装完成,环境变量配置没有问题,cmd窗口运行mvn compile的时候报错如下

Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved:
Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6:
Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.52.215] failed: Connection timed out: connect -> [Help 1]

本人用了第4中办法才成功!

解决方案:

1  经红色字体可以得知,不能在https://repo.maven.apache.org/maven2这个网址下载到maven-resources-plugin:jar:2.6jar包,于是我浏览器访问了红色网址,可以访问的到。

2  我把从其他地方得到的2.6的maven-resources-plugin jar包和pom相关文件放到maven指定的目录下,可是错误依旧,尝试失败。

3  从网上搜到这种问题的解决方案之一:是在pom.xml中加入依赖如下,

org.apache.maven.plugins maven-resources-plugin 2.6

有些人用这个方法解决了问题,但是我的问题依旧;

4  开始放大招了,最后搜索到一种方法,直接把maven安装文件夹的conf文件夹下的 settings.xml文件配置如下:

复制代码

mirrorId central Human Readable Name http://repo1.maven.org/maven2/
<mirror> 
<id>alimaven</id> 
<name>aliyun maven</name> 
<url>http://central.maven.org/maven2</url> 
<mirrorOf>central</mirrorOf> 
</mirror> 
<mirror> 
<id>alimaven</id> 
<name>aliyun maven</name> 
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url> 
<mirrorOf>central</mirrorOf> 
</mirror> 




<!-- junit镜像地址 -->
<mirror> 
<id>junit</id> 
<name>junit Address/</name> 
<url>http://jcenter.bintray.com/</url> 
<mirrorOf>central</mirrorOf> 
</mirror>

复制代码

,最后问题得以解决。

这种问题出现的原因就是,联通的网段,无法访问maven.org网站。

  • 12
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值