maven 本地依赖存在但还是报依赖无法找到的错误

情况

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

  1. 正确的解决方式:增加命令行参数 --legacy-local-repository 避免maven查询远程仓库的依赖
  2. 删除错误jar依赖仓库中所在文件夹的 _remote.repositories 的文件

参考

  • https://stackoverflow.com/questions/32571400/remote-repositories-prevents-maven-from-resolving-remote-parent
  • http://maven.40175.n5.nabble.com/Cannot-find-parent-POM-but-it-s-there-td5776845.html

你可能感兴趣的:(Maven)