在最近的项目中,频繁遇到这样一个问题,以project的形式导入一个新的微服务项目时,会出现所有的依赖全都报错的问题,是所有的依赖。没想明白这个原因,试过所能搜到的解决方式都无效,最后的解决方案是借助一个无关项目,打开一个新的idea窗口,在这个新的窗口中以module形式打开目标项目,在重新导入依赖即可。
迄今为止仍未找到具体原因,后续有待探究。
另外,在查找解决方案过程中发现阿里云的远程仓库镜像地址变了。这需要注意一下。
更新:
刚发现一种新的行之有效的解决方案,就是直接将maven的setting文件中的与阿里云镜像相关的配置删掉或者注掉,目的是让项目直接读取本地仓库的资源而非首选从阿里云下载,但是使用本方法需要注意,必须要确认你所需要的包都已经存在于你的本地仓库中才可以。具体来说就是将settings文件中mirror标签 和profiles标签下的内容,如下:在这里插入代码片
`<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>````
```html
<profiles>
<profile>
<id>test</id>
<repositories>
<repository>
<id>nexus</id>
<name>nexus-repository</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>nexus-repository</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>```
删掉或注释掉
另附settings.xml文件中的标签详解:
https://www.cnblogs.com/kevinlogs/p/9130979.html
8.21更新:
再次修订该方法,除了需要修改setting文件以外还要注意pom.xml配置文件中是否也有对于maven远程仓库的设置,如果有也要注释掉,最终目的就是确保maven项目用的是你本地仓库并且要确保你本地仓库中该有的依赖jar包都有。