解决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>
相关文章
Spring中的@ControllerAdvice和@ExceptionHandler注解处理全局异常
这篇文章主要介绍了Spring中的@ControllerAdvice和@ExceptionHandler注解处理全局异常,@ControllerAdvice ,@ControllerAdvice是一个非常有用的注解,顾名思义,这是一个增强的 Controller,一般配合@ExceptionHandler使用来处理全局异常,需要的朋友可以参考下2024-01-01
Springboot Retry组件@Recover失效问题解决方法
在使用springboot的retry模块时,你是否出现过@Recover注解失效的问题呢?不用担心,这篇文章就来告诉你解决@Recover失效的办法,需要的小伙伴可以参考一下2021-11-11


最新评论