关键词:
- IntelliJ IDEA
- Maven 依赖下载超时报错
前言
在新环境用 Maven 时,踩坑各种 Maven 报错、超时。
Maven 配置阿里源
- 将以下内容写到
~/.m2/settings.xml
(注意先备份原来存在的settings.xml
):
<?xml version="1.0" encoding="UTF-8"?>
<settings
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<repositories>
<repository>
<id>spring</id>
<url>https://maven.aliyun.com/repository/spring</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>google</id>
<url>https://maven.aliyun.com/repository/google</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-plugin</id>
<url>https://maven.aliyun.com/repository/spring-plugin</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>apache</id>
<url>https://maven.aliyun.com/repository/apache-snapshots</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
- 在命令行跑
mvn help:effective-settings
可以看到是否有效
设置 IDEA
-
对于新 Project 需要从这里设置:
-
对于当前项目则需要从这里设置
-
随后,设置以下:
settings.xml
路径:
- 在 Importing 的
VM options for importer
和 Runner 的VM Options
加入:-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
-
记住 Maven 下依赖报错的万能(几乎)解决方式 3 步骤(循环做几遍):
- maven clean
- maven install
- Reload All Maven Projects
- maven clean
至于没用?
尾巴
好的,感谢你看到这里,对文章有错误的地方欢迎指出,谢谢。
如果觉得本文写得不错,不妨点赞、评论、收藏、分享,你的三连是对我最大的支持!
我的 Github:zhangt2333’s Github
我的 CSDN:zhangt2333’s CSDN
我的 博客园:zhangt2333’s cnblog
本文作者:zhangt2333
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议 。转载请注明出处!