dependencies.dependency.version is missing even though the dependency is already declared in its parent's pom file's dependency management section

若如初见. 提交于 2019-12-03 06:26:52
Hui Wang

It's true that the parent pom has already included the dependency declaration in the dependency management section. But it's not taken into account. To do so, we should execute the command to install the pom file in the local maven repo.

mvn -f <the absolute path to the parent's pom file> install -N

Be aware that when maven resolves dependencies, it always looks for pom files already available in the repo. Instead, local files are not taken into account.

Another reason why Maven complains about missing dependency is when dependency declared in parent pom has < type> that doesn't correspond to the type that the child pom is looking for.

I would have added this as a comment to Hui Wang's answer, but for some reason commenting seems disabled.

Anyway, in my case, I had to use the following command:

mvn -f <path to the parent's pom file> install -N

I'm using maven 3, so maybe it's different from maven 2.

I couldn't get Hui's command to work without the -f, and it wasn't necessary for the parent pom file's path to be absolute (both relative and absolute worked).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!