Maven dependency resolution works by recursively fetching a project's declared dependencies and their own transitive dependencies from configured repositories, building a full dependency tree, and applying conflict resolution rules — nearest declaration wins, with first-declared as a tiebreaker at the same depth — when the same artifact appears at different versions.
Key Points: • Maven checks the local repository (~/.m2) first, then falls back to remote repositories defined in pom.xml or settings.xml. • Direct dependencies are declared explicitly; transitive dependencies are pulled in automatically from those dependencies' own POMs. • When multiple versions of the same artifact appear in the tree, Maven's "nearest wins" rule picks the version closest to the root project in the dependency graph. • dependencyManagement overrides this default resolution by pinning an explicit version regardless of depth. • dependency:tree is the standard tool for visualizing the resolved tree and diagnosing conflicts.
Example: On one project, two modules each depended on a different version of a shared logging library through separate transitive paths; dependency:tree revealed the actual conflict, and adding an explicit version in the parent POM's dependencyManagement forced a single consistent version across all modules.
Interview Tip: A concise interview answer is:
"Maven builds a full dependency tree from direct and transitive dependencies, and resolves conflicts using a nearest-wins rule when multiple versions of the same artifact appear. When I've hit conflicts, I used dependency:tree to see exactly which modules were pulling in which version, then pinned the correct one in dependencyManagement so it took precedence everywhere."