IDEA无法下载maven依赖 解决IDEA无法下载maven依赖的问题
stephenChen946 人气:0想了解解决IDEA无法下载maven依赖的问题的相关内容吗,stephenChen946在本文为您仔细讲解IDEA无法下载maven依赖的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:IDEA无法下载maven依赖,IDEA下载maven依赖,下面大家一起来学习吧。
今天新建一个springboot项目时,项目建好后,在IDEA下载依赖包时,下载了很久都没有下载完,后来仔细一看,是下载不了。
解决方法:
在项目的pom.xml文件上右键,弹出框中选择maven,再选择open 'settings.xml' 或者是 create '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>nexus</id> <name>internal nexus repository</name> <!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>--> <url>http://repo.maven.apache.org/maven2</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> </settings>
重新右键pom.xml文件,选择 maven ,选择 Reimport 即可下载依赖。操作步骤及settings.xml文件内容如图:
settings.xml文件内容:
至此,依赖依法下载的问题已经解决。。
疑惑:将settings.xml文件中的<mirrors>替换成如下内容,竟然也无法下载依赖(但看网上博客说会让下载速度变快的)
<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> <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://192.168.1.100:8081/nexus/content/groups/public/</url>--> <url>http://repo.maven.apache.org/maven2</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>
加载全部内容