Avoiding repetitive groupId and version tags and inherit from the parent POM

In a multi-module Maven project, most of the modules (if not all) share the same groupId and version elements. In this case, you can avoid adding the version and groupId elements to your application POM file. These will be automatically inherited from the corresponding parent POM.

If you look at axis2-kernel (which is a module of the Apache Axis2 project), you will find that no groupId or version is defined at http://svn.apache.org/repos/asf/axis/axis2/java/core/trunk/modules/kernel/pom.xml. Maven reads them from the parent POM file:

<project> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.axis2</groupId> <artifactId>axis2-parent</artifactId> <version>1.7.0-SNAPSHOT</version> ...

Get Mastering Apache Maven 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.