'What is a transitive Maven dependency?

This question is about to clarify what exactly a transitive dependency is and how it works at very high level in Maven.

My definition: in a dependency tree like A --> B --> C, C is a transitive dependency for A. Assume B has scope compile within A.

If C has scope compile within B, then declaring B as dependency of A suffices to build A with Maven. But if C has scope provided within B then, when Maven builds A, the building will not automatically compile A against C unless A declares C among its dependencies.

Is this correct?



Solution 1:[1]

As an example, if we added JUnit as a dependency in pom.xml under <dependencies> tag. It will download the other hamcrest-core-1.3.jar file and it is under Maven Dependencies, This .jar file can be called Transitive dependency.

enter image description here

Resource:- https://youtu.be/ypVE8EgDzzI

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1