Maven parent pom vs modules pom
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
In Maven, "parent POM" and "modules POM" are related ideas, but they are not the same concept. A parent POM is about inheritance of configuration. A POM with a modules section is about aggregation and build coordination. One file can play both roles, but you should understand them separately or multi-module builds become confusing very quickly.
What a Parent POM Does
A parent POM provides shared configuration that child projects inherit. Typical parent-level content includes:
- dependency versions in
dependencyManagement - plugin versions in
pluginManagement - shared properties
- repository and build settings
A child module points to the parent using the parent section.
That tells Maven to inherit configuration from the parent POM.
What a Modules POM Does
A POM with a modules section is an aggregator. Its job is to tell Maven which subprojects belong to the build.
When you run Maven at this top level, it builds the listed modules in the right order.
So aggregation is about "which projects are in this build." Inheritance is about "which configuration do these projects share."
One POM Can Be Both
A common structure is a top-level POM that acts as both:
- the parent for child modules
- the aggregator that lists those modules
That is common, but it is a design choice, not a Maven rule.
They Can Also Be Separate
Large organizations sometimes separate the roles.
For example:
- one corporate parent POM provides standard plugin and dependency management
- another aggregator POM collects the modules for a particular build
This is useful when many projects share the same parent but are not part of the same multi-module reactor build.
How Child Modules Usually Look
A child module typically inherits from the parent and defines its own artifact-specific dependencies.
The dependency version can be omitted because the parent manages it.
dependencyManagement Is Not the Same as Modules
Another source of confusion is mixing up dependency inheritance with project aggregation. The modules section tells Maven which subprojects participate in the reactor build. dependencyManagement tells child projects which dependency versions to inherit when they declare those dependencies.
Those are different jobs:
- '
modulescontrols build composition' - '
dependencyManagementcontrols version alignment'
Understanding that distinction helps explain why a parent POM often contains both sections even though they solve separate problems.
The Core Difference
The cleanest summary is:
- parent POM: controls inheritance
- modules POM: controls aggregation
That is why a POM can list modules without being their parent, and a POM can be a parent without listing modules at all.
Common Pitfalls
- Assuming any POM with
modulesautomatically acts as the parent for those modules. - Assuming any parent POM must also aggregate modules in the same repository.
- Putting dependency versions directly in each child instead of centralizing them in
dependencyManagement. - Confusing
dependencyManagementinheritance with actual dependency inclusion. - Forgetting that
packagingshould usually bepomfor parent or aggregator POMs.
Summary
- A parent POM is for inheritance of shared Maven configuration.
- A modules POM is for aggregating subprojects into one reactor build.
- One top-level POM can serve both roles, but they are still separate concepts.
- Child modules usually reference the parent with the
parentelement. - Understanding inheritance versus aggregation makes multi-module Maven builds much easier to reason about.
Related reading
- Maven plugin for versioning and minifying javascript
- Maven Plugin not found in IntelliJ IDE
- Maven plugins can not be found in IntelliJ
- Maven profiles equivalent of Gradle
- Maven resource filtering not working - because of spring boot dependency
- Maven Resource Filtering with Spring Boot Could not resolve placeholder
- Maven Run Project
- Maven Spring Boot Failed to instantiate SLF4J LoggerFactory Reported exception

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.