解決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)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
這個錯誤着實讓我頭疼,在網上找了大量的解決辦法一直不奏效,最后自己慢慢摸索出來了一個解決辦法,原理不是很明確,但是確實解決了我這個問題,所以記錄下來與大家分享,希望能幫助有需要的人。
一、
首先打開maven解壓目錄下的conf文件夾里的setting.xml,在其中添加如下倉庫位置和插件下載url(因為默認的是在國外,在這里我們改成阿里雲的國內鏡像)
<localRepository>E:\apache-maven-3.6.0\repository</localRepository>
- 1
這個倉庫路徑是你自己選的,需要存在這個路徑(我是直接在maven的解壓文件夾里創建了一個repository)
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
- 1
- 2
- 3
- 4
- 5
- 6
添加阿里雲的國內鏡像地址。
保存之后退出。
二、
在IDEA中依次按照路徑file-setting找到maven配置選項(如下圖),將如下兩項修改:第一項修改為maven解壓目錄下的conf文件夾里的setting.xml,第二項會自動讀取setting.xml文件里的倉庫地址(如果未自動讀取,檢查下自己是否寫錯了),也可以手動更改。更改完成之后點擊Apply-OK。
之后重啟IDEA,新建maven項目,就可以發現上面的錯誤不見啦。