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 17:35:27

问题


As described, the dependency:tree goal on my my project complains that the dependency version is missing for a dependency that is already declared in the dependency management section of its parent pom. Please note the dependency in question is a new one and is just added in the management section.


回答1:


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.




回答2:


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.




回答3:


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).



来源:https://stackoverflow.com/questions/12900525/dependencies-dependency-version-is-missing-even-though-the-dependency-is-already

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