解决Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies...

解决Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies could not be resolved的问题

最近在学习JAvaWeb,在第一次使用IDEA(以前没用过)创建maven项目时,老是创建不成功,文件残缺,下面是错误提示。

[WARNING] Could not transfer metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): Received fatal alert: protocol_version
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.282 s
[INFO] Finished at: 2019-01-05T18:29:17+08:00
[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 (E:\apache-maven-3.6.0\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解压目录下的conf文件夹里的setting.xml,在其中添加如下仓库位置和插件下载url(因为默认的是在国外,在这里我们改成阿里云的国内镜像)

<localRepository>E:\apache-maven-3.6.0\repository</localRepository>

这个仓库路径是你自己选的,需要存在这个路径(我是直接在maven的解压文件夹里创建了一个repository)
解决Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies...

<mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>       
    </mirror> 

添加阿里云的国内镜像地址。
解决Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies...
保存之后退出。
二、
在IDEA中依次按照路径file-setting找到maven配置选项(如下图),将如下两项修改:第一项修改为maven解压目录下的conf文件夹里的setting.xml,第二项会自动读取setting.xml文件里的仓库地址(如果未自动读取,检查下自己是否写错了),也可以手动更改。更改完成之后点击Apply-OK。
解决Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies...
之后重启IDEA,新建maven项目,就可以发现上面的错误不见啦。
解决Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies...
可以开心地跟IDEA玩耍啦~~~
如果有问题欢迎与我交流。