Search code examples
dependenciesmaven-3dependency-managementtransitive-dependency

Maven exclude dependency of transitive dependency


I have this dependency tree: A->B->C->D. A is the main project. I would like to know if it’s possible to exclude only D from A without needing to add explicitly C to A? Thanks


Solution

  • Please refer following maven documentation which contains an example and covers your use case:

    https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

    Following is example snapshot for quick reference:

    enter image description here