Maven exclude transitive dependency of a transitive dependency

本小妞迷上赌 提交于 2019-11-30 19:27:20

问题


Is there a syntactic way in a pom file to exclude a dependency of a transitive dependency.

For example, if A has a dependency B and B has a dependency C and C has a dependency on D, a way to exclude dependency D when compiling A.

Exclusions for a dependency only seem to go one level deep.

How I have accomplished this in the past is to include dependency C in A's pom and then add the exclusion for D in C's dependency declaration. Is this the recommended way?


回答1:


You can add an <exclusions> element for D to the dependency B in the POM of A. Exclusions work recursively on transitive dependencies.

A good way to do this for a complex project is to use an <dependencyManagement> element in the parent POM which excludes anything you don't want to see anywhere.



来源:https://stackoverflow.com/questions/21114236/maven-exclude-transitive-dependency-of-a-transitive-dependency

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