IDEA Spring Boot 加载 pom.xml 文件出错
- 之前学习Spring Boot RabbitMQ,遇到spring-boot-starter-amqp 加载失败的问题,一度以为maven或者IDE有问题,所以等我把IDEA和maven重装到最新版本后,反倒是完全不能加载任何依赖了,就这样卡了好多天
解决方法
- 重装maven后,确保有 ${user.home}/.m2/repository 这个路径,先不要移动这个路径(可以选择用我的覆盖:.m2.zip 提取码:ltsc )
- 打开settings.xml,Ctrl + F 找到
<localRepository>
修改本地仓库路径
我是把maven安装在D盘:<localRepository>D:/Maven/repository</localRepository>
- 打开 IDEA, 先确认IDE设置是否有误,File – Settings
- 新建项目修改 settings.xml 文件
- 如果这个时候项目还是加载不出来,那么
- Ctrl + F 找到
<mirrors>
, 将以下代码覆盖上去,即换源,之后 maven – reimport 重新加载<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>nexus</id> <name>internal nexus repository</name> <url>http://repo.maven.apache.org/maven2</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>
- 等待依赖成功加载,可能会比较久,之后问题成功解决