Microservices parent and aggregator POM

Microservices parent and aggregator POM

Microservices is a variant of the service-oriented architecture structural style, that organizes an application as a collection of loosely coupled services. Each service is a self-contained piece of business functionality, and a complete application typically consists of multiple projects (multi-module project). As the number of projects grows larger, it becomes a nuisance to build each project separately.

Each project, in Maven architecture, includes it’s own POM file. These files define dependencies, plugins, resources, etc. relevant to the project.

Problem 1 – duplication of code, difficult maintenance

Many of POM definitions (dependencies, plugins, resources,…) might be equivalent to other modules, so, we find ourselves repeating XML contents. Here is where parent POM comes into play.

A parent POM enables us to define an inheritance style relationship between POMs. POM files at the bottom of the hierarchy (child POMs) declare that they inherit from a specific parent POM. The parent POM is used to share common properties and details of configuration.

This simplifies our child POMs, but doesn’t really follow the idea of microservices. Microservices are a way of breaking our application down into standalone independent applications that can be run on different hardware or server instances.

In case of a parent POM, every child must reference it.

Problem 2 – managing submodules

To simplify building, testing and deploying multiple projects, we can create an aggregate POM. Moreover, it is usually necessary to build projects in a certain order and the developer must remember to follow the correct build order. The aggregate POM file specifies which sub-projects (or modules) to build and builds them in the specified order. It’s a top-level module serving for joining multiple modules under one roof and represents them as a parts of a greater whole.

An aggregate POM specifies only the minimal POM and modules. Minimal POM’s requirements are project root, model version, group id, artifact id and version.


Both aggregate and parent POM are placed in the parent directory of the individual projects. Also, an upper level POM can be parent and aggregate at the same time.

Tags: , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *