解决IDEA中Maven下载依赖包过慢或报错的问题
在初步建立好项目后,Maven在下载依赖,等了很久,始终有4个依赖报错,通过网上查询,找到了解决方案:
问题原因:导致IDEA Maven下载依赖包速度过慢,有很大一部分原因是因为需要请求到国外镜像仓库,响应比较慢,遂会造成等待时间久、相应报错的问题。
解决方案:
1.鼠标右击自己的项目,找到【Maven】

2.选择【Open ‘settings.xml'】或者【Create ‘settings.xml’】


3.将以下代码粘入文件中,重启IDEA后即可提高速度
【设置Maven镜像库为阿里云镜像库和Junit镜像库】
<?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>mirrorId</id>-->
<!-- <mirrorOf>repositoryId</mirrorOf>-->
<!-- <name>Human Readable Name for this Mirror.</name>-->
<!-- <url>http://my.repository.com/repo/path</url>-->
<!-- </mirror>-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>uk</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://uk.maven.org/maven2/</url>
</mirror>
<mirror>
<id>CN</id>
<name>OSChina Central</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>nexus</id>
<name>internal nexus repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
<!-- junit镜像地址 -->
<mirror>
<id>junit</id>
<name>junit Address/</name>
<url>http://jcenter.bintray.com/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<!-- <mirrors>-->
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<!--This sends everything else to /public -->
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>osc</id>
<mirrorOf>*</mirrorOf>
<url>http://maven.oschina.net/content/groups/public/</url>
</mirror>
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
<mirror>
<id>net-cn</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://maven.net.cn/content/groups/public/</url>
</mirror>
<mirror>
<id>ui</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://uk.maven.org/maven2/</url>
</mirror>
<mirror>
<id>ibiblio</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
</mirror>
<mirror>
<id>jboss-public-repository-group</id>
<mirrorOf>central</mirrorOf>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>JBossJBPM</id>
<mirrorOf>central</mirrorOf>
<name>JBossJBPM Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
</mirror>
</mirrors>
</settings>截止到此,Maven的依赖包就能很快速的下载了。
另一种解决方案
1.设置Maven镜像仓库
在Maven文件夹下找到【conf】文件夹下,找到【setting,xml】,编辑此文件,如果里面已经配置了阿里云镜像库和Junit镜像库则跳过,如果没有则进行插入。

2.编辑【setting】


以上就是解决IDEA中Maven下载依赖包过慢或报错的问题的详细内容,更多关于IDEA Maven下载过慢或报错的资料请关注脚本之家其它相关文章!
相关文章
SpringBoot v2.2以上重复读取Request Body内容的解决方案
这篇文章主要介绍了SpringBoot v2.2以上重复读取Request Body内容的解决方案,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2021-10-10
详解SpringBoot定制@ResponseBody注解返回的Json格式
这篇文章主要介绍了详解SpringBoot定制@ResponseBody注解返回的Json格式,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2020-11-11
java ArrayList.remove()的三种错误用法以及六种正确用法详解
这篇文章主要介绍了java ArrayList.remove()的三种错误用法以及六种正确用法详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2020-01-01
springboot中的springSession的存储和获取实现
这篇文章主要介绍了springboot中的springSession的存储和获取实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2020-09-09
安装elasticsearch-analysis-ik中文分词器的步骤讲解
今天小编就为大家分享一篇关于安装elasticsearch-analysis-ik中文分词器的步骤讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧2019-02-02


最新评论