情况
一般是存在于假设有私服的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
的文件