关于“Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE ...could not be resolved”的问题解决

最近,在使用maven创建web工程时,遇到了项目初始化一直失败的问题。具体报错信息如下:

[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml. Return code is: 501 , ReasonPhrase:HTTPS Required.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.640s
[INFO] Finished at: Tue Feb 04 00:02:33 CST 2020
[INFO] Final Memory: 6M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Failed to resolve version for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Could not find metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml in local (C:\Users\hp\.m2\repository) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
[ERROR] Maven execution terminated abnormally (exit code 1)

这个问题困扰我很久,阻挠了项目的进行,在多番了解以后,原来是因为maven下载资源默认都是apache的国外服务器进行下载的,导致速度慢常会出错。为了能够把这个问题彻底解决,同时也提高资源下载速度,我们可以使用maven中央仓库在国内的代理服务器进行下载,这里我使用的是阿里云提供的maven私有仓库服务。具体做法如下:

首先,从阿里云提供的maven私服网站(https://maven.aliyun.com/mvn/view)上,选择public服务器的地址,

 

然后,在本地的maven安装目录中conf/settings.xml文件中,修改服务器地址,

<mirror>
    <id>aliyun-maven</id>
    <name>aliyun-maven</name>
    <url>https://maven.aliyun.com/repository/public</url>
    <mirrorOf>central</mirrorOf>       
</mirror> 

我自己对maven的本地仓库地址也进行了修改,没有使用用户目录下的.m2默认仓库地址,

我使用的是IntelliJ IDEA 开发工具,对maven的“User setting file”设置成maven安装目录中的settings.xml文件,“Local repository”会根据settings.xml文件中设置的本地仓库地址自动同步。

经过上述设置,就可以使用阿里云的maven私有仓库服务了,创建maven的web项目,初始化也没有问题了。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值