关于“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服务器的地址,

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

 

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


    aliyun-maven
    aliyun-maven
    https://maven.aliyun.com/repository/public
    central       
 

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

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

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

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

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

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

你可能感兴趣的:(解决方案)