Dependency

This lesson talks about adding artifacts as Maven dependencies and their management, one of the most important features of Maven.

We'll cover the following...

One of the tasks Maven excels at is handling dependencies for a given project. It can also handle transitive dependencies, which means if your project P depends on a jar A, which in turn depends on jar B, then Maven would download both the dependencies for you. In this case, jar A will be referred to as a direct dependency while jar B will be considered a transitive dependency for your project P. If jar B is in turn dependent on jar C, and jar C is in turn dependent on jar D, Maven will also download jars C and D when building your project P. Jars B, C, and D will collectively be called as transitive dependencies.

Maven can also resolve any dependency version conflicts and allow certain dependencies to be excluded. But how is Maven able to determine the complete set of dependencies for a given project? This is made possible by the POM file that is also installed for an artifact in the repository. Recall that the empty-project-1.jar artifact ...