Maven exclude transitive dependency of a transitiv

2019-02-20 10:14发布

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条回答
冷血范
2楼-- · 2019-02-20 11:08

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.

查看更多
登录 后发表回答