What are groupId, artifactId and version in Maven?
BeginnerConceptJava builds (Maven, Gradle, JAR, WAR)
Answer
Short answer
They are the coordinates that uniquely identify a Maven project or library — like a full postal address. groupId is the organisation (com.shop), artifactId is the project name (orders), and version is the release (1.4.0). Together they produce the artifact name orders-1.4.0.jar.
Example
<groupId>com.shop</groupId>
<artifactId>orders</artifactId>
<version>1.4.0</version>
- Built file:
target/orders-1.4.0.jar - Path in Nexus /
~/.m2:com/shop/orders/1.4.0/orders-1.4.0.jar
Dependencies are referenced the same way:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.3</version>
</dependency>
SNAPSHOT vs release
1.4.0-SNAPSHOT— "work in progress". Can be overwritten in the repository; Maven re-checks for newer snapshots.1.4.0— a release. Immutable: once published, it must never change.
What to say in the interview
"groupId, artifactId and version are Maven coordinates. They uniquely identify an artifact in a repository like Nexus. SNAPSHOT versions are mutable development builds; release versions are immutable, so we only deploy release versions to production."
All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: Java apps: Maven, Gradle, JAR & WAR
More on Java builds (Maven, Gradle, JAR, WAR)
What is pom.xml and what is it used for?BeginnerHow do you build and run a Java project with Maven?BeginnerWhat is the difference between a JAR and a WAR file?BeginnerWhat is Gradle and how is it different from Maven?BeginnerHow do you configure a Spring Boot application for different environments?BeginnerA Maven build fails in the pipeline with "Could not resolve dependencies". How do you fix it?Intermediate