Lesson 47: Building & Running with Maven
17 Aug 2026 1 min Swarnil Singhai
Maven manages dependencies and standardizes the build lifecycle (compile, test, package) via a declarative pom.xml instead of hand-rolled scripts.
Real-time example
A team's CI pipeline runs mvn test on every pull request — the same command every developer runs locally, guaranteeing consistency.
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.3</version>
</dependency>
</dependencies>
<!-- mvn compile / mvn test / mvn package -->
What's happening
Maven downloads the exact declared version of every dependency (and their transitive dependencies) into a shared local repository (~/.m2).
Pin dependency versions explicitly — 'latest' resolution has broken more production builds than almost anything else in Java tooling.
Advertisement