情况
一般是存在于假设有私服的maven项目中。明明依赖的Jar包已经在本地仓库中存在,但是编译的时候还是出现依赖错误,Could not resolve dependencies for project。
原因
Maven 3.0+ enforces that downloaded artifacts were resolved from a repository url/id that matches an url available for the current session.
解决
IIRC there is a CLI option that you can enabled in Maven 3.1.1 that tells Maven “I know what I am doing and don’t make that check this time” i.e. --legacy-local-repository
- 正确的解决方式:增加命令行参数
--legacy-local-repository避免maven查询远程仓库的依赖 - 删除错误jar依赖仓库中所在文件夹的
_remote.repositories的文件
Maven依赖错误解决
本文详细解析了在Maven项目中遇到的Couldnotresolvedependencies错误,解释了Maven3.0+对下载的artifacts的严格检查机制,并提供了两种有效的解决方案:一是使用--legacy-local-repository参数,二是删除_remote.repositories文件。
3424

被折叠的 条评论
为什么被折叠?



