Maven POM Inheritance and Aggregation
Fast recall
Quick revision
Core answer
. POM aggregation allows a root POM declared with to build multiple child modules together. A POM can be both a parent and an aggregator, but they serve distinct purposes.Whether you understand how to share configuration across modules without duplication and how multi-module builds are orchestrated.
Confusing inheritance (configuration sharing) with aggregation (build orchestration). A child can inherit from a parent that is not in the same build, and an aggregator can include modules that have a different parent.
Mention that Spring Boot's `spring-boot-starter-parent` uses POM inheritance to provide dependency management, plugin configuration defaults, and resource filtering. Also mention `<relativePath>` in the `<parent>` block.
Interview-ready guide
Interview answer
POM inheritance and aggregation look like the same thing from a distance but solve completely different problems. Inheritance is about sharing configuration — a parent POM defines managed dependency versions and plugin defaults that children inherit. Aggregation is about build orchestration — a root POM lists submodules and Maven builds them in the correct order.
Inheritance — configuration sharing
- When a child POM declares
, it inherits properties, plugin configuration, andfrom the parent — inheriting fromspring-boot-starter-parentgives you aligned versions for all Spring and Jackson libraries without declaring a single version yourself defines which version to use without pulling the dependency in — children still explicitly declare what they need; the parent only controls which version is selected when they do- A child can inherit from a parent in a completely different repository — that is exactly what every Spring Boot project does with
spring-boot-starter-parent; the parent does not need to be part of the same build
Aggregation — build orchestration
- The root POM's
block lists subproject directories; runningmvn installat the root triggers the Maven Reactor, which computes dependency order automatically - If
servicedepends oncore, Reactor buildscorefirst without any explicit ordering configuration — it infers order fromreferences between modules - The most useful Reactor command is
mvn install -pl :service -am— it builds only the target module and its dependencies, skipping unrelated modules; essential in large multi-module projects with slow full builds
Combining both roles
- Most projects combine both in the root POM:
with both apom block and asection - The two mechanisms are independent — you can aggregate modules that inherit from different parents, and you can inherit from a parent without being part of its aggregation
Maven POM Inheritance and Aggregation
Direct Answer
POM inheritance allows a child module to inherit configuration (dependencies, plugins, properties) from a parent POM declared with <parent>. POM aggregation allows a root POM declared with <modules> to build multiple child modules together. A POM can be both a parent and an aggregator, but they serve distinct purposes.
Common Mistakes & Pitfalls
Confusing inheritance (configuration sharing) with aggregation (build orchestration). A child can inherit from a parent that is not in the same build, and an aggregator can include modules that have a different parent.
Check your understanding
Answer these without looking back at the article.
- What is the difference between `<dependencyManagement>` and declaring a dependency directly?
- How do you override a parent property in a child POM?
- Can a Maven module have a different parent from the aggregator root?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.