tezvyn:

Maven Coordinates (GAV): The Address of Your Code

AI-drafted, machine-checkedSource: maven.apache.orgintermediate

Maven Coordinates (GAV) are like a postal address for a software library. You use them in a `pom.xml` to declare your project's identity and specify its dependencies.

WHY IT EXISTS Before standardized coordinates, managing Java libraries (JAR files) was chaos. Developers manually downloaded files, added them to a project's classpath, and hoped for the best. Maven introduced coordinates to create a predictable, automated system for uniquely identifying, locating, and retrieving any artifact in the vast Java ecosystem.

THE MENTAL MODEL Think of Maven Coordinates as a postal address for a piece of software. This address has three parts, often called GAV: the GroupId, ArtifactId, and Version. The GroupId is like the city and state (the owning organization), the ArtifactId is the street address (the specific library's name), and the Version is the apartment number (the exact release). This triplet forms a unique key in a global database of artifacts like Maven Central.

HOW IT WORKS The GAV coordinates are declared in a project's pom.xml file. The triplet consists of: first, groupId, a unique identifier for the project's organization, typically in reverse domain name notation (e.g., org.apache.commons). Second, artifactId, the name of the specific project or sub-project (e.g., commons-lang3). Third, version, the specific release of the artifact (e.g., 3.12.0). When Maven builds a project, it reads the coordinates in the <dependencies> section, searches for them in your local repository, and if not found, downloads them from a remote repository.

WHEN TO USE IT GAV coordinates are fundamental to every Maven project. You declare your own project's GAV at the top of its pom.xml. You use them every time you add a new dependency, inherit from a parent project, or configure a multi-module build. They are the universal language for dependency management in the Java world, also understood by other build tools like Gradle and Ivy.

WHEN NOT TO USE IT The GAV scheme is specific to the Maven ecosystem. While the concept of a unique package identifier is universal, the syntax is not. Other ecosystems have their own standards, such as name@version in npm for JavaScript, module paths for Go, or group/name on PyPI for Python. You wouldn't use GAV coordinates to manage dependencies in a Node.js or Python project.

ONE CANONICAL EXAMPLE To include the Spring Boot Web Starter library in a project, you would add the following to your pom.xml's <dependencies> section:

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>3.1.5</version> </dependency>

This tells Maven to find the project owned by org.springframework.boot, locate the specific artifact named spring-boot-starter-web, and download version 3.1.5 and all of its required transitive dependencies.

Read the original → maven.apache.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.