使用原型骨架创建Maven项目时遇到Could not transfer metadata org.apache.maven.plugins的解决方案

在使用骨架创建maven项目时,提示无法下载的问题Could not transfer metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml from/to aliyunmaven (https://maven.aliyun.com/repository/public): Transfer failed for https://maven.aliyun.com/repository/public/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml。

我在之前已经部署了阿里云的maven镜像,但还是无法下载相关文件,导致创建失败。

在网上查到相关解决方案,是需要设置忽略ssl证书验证,但是IDEA 2020版本后将全局设置放在了下图所示位置,我个人是先在File-Settings(仅对本项目生效)里设置了忽略ssl证书验证的参数,不知道为什么,重新build项目仍会失败。所以重点是,要在全局设置里去设置忽略ssl证书验证。

使用原型骨架创建Maven项目时遇到Could not transfer metadata org.apache.maven.plugins的解决方案

所以我们进入File-New Projects Settings-Settings for New Projects,然后在下图的VM options for importer中加入如下参数

-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true

使用原型骨架创建Maven项目时遇到Could not transfer metadata org.apache.maven.plugins的解决方案

然后再继续在下图VM Options中加入上面同样的参数,保存即可。再创建新的Maven项目就发现bulid success了。

使用原型骨架创建Maven项目时遇到Could not transfer metadata org.apache.maven.plugins的解决方案