skip to content

Effective POM & Model

Model merging against the super POM and the help:effective-pom view of what Maven will really run. Asked because reading the effective POM is the fastest way to answer 'where did this setting come from?'

on this pageshow

questions

5

What is the 'effective POM' in Maven, and how does it differ from the pom.xml you write by hand?

level: juniorimportance: must knowfreq 70%

answer

  1. computed final model
  2. Super POM defaults
  3. merge parents + profiles
  4. help:effective-pom
  5. explicit vs authored

basics

~10 s

The effective POM is the final, fully-merged project model Maven actually builds with. It combines your pom.xml with the built-in Super POM, parent POMs, and active profiles, filling in all defaults.

solid answer

~40 s

The effective POM is the complete, computed project model Maven uses at build time. Your hand-written pom.xml is usually small; Maven merges it on top of the built-in Super POM (which supplies default repositories, build directories like target/, and core plugin bindings), then layers any parent POMs, dependency/plugin management, settings, and active profiles. The result is a fully-resolved model with every default and inherited value made explicit. You inspect it with `mvn help:effective-pom`. This matters for debugging: when you wonder 'where did this repository / plugin version / source directory come from?', the effective POM shows the resolved truth rather than the sparse file you authored.

code

bash · 2 lines
bash
mvn help:effective-pom
mvn help:effective-pom -Doutput=effective-pom.xml

go deeper

for a junior

Knows the effective POM is the merged final model and that help:effective-pom prints it.

for a middle

Can list the merge layers (Super POM, parents, project, profiles) and what each contributes.

for a senior

Uses the effective POM to debug surprising plugin versions, repositories, or properties and explains precedence.

for a principal

Designs parent/BOM hierarchies knowing how the effective model resolves, and teaches teams to reason from it.

## What the effective POM is When you write a `pom.xml`, you only specify what differs from defaults. Maven does NOT build from that sparse file directly. Instead it computes an **effective POM**: the complete project model after merging several layers, with every default and inherited value resolved to a concrete value. ## The layers that get merged (lowest to highest precedence) 1. **Super POM** — a POM built into Maven itself (it is the implicit parent of every project). It supplies sensible defaults: the Central repository, default directories (`src/main/java`, `target/`, `target/classes`), default resource locations, and bindings for core plugins. You never see it as a file; it ships inside `maven-model-builder`. 2. **Parent POM(s)** — if your project declares a `<parent>`, its values are inherited, and parents can themselves have parents, forming an inheritance chain rooted at the Super POM. 3. **Your project's pom.xml** — your explicit declarations override inherited ones. 4. **Active profiles** — profiles (from the POM, `settings.xml`, or `~/.m2/settings.xml`) that are active inject/override values into the computed model. ## The required header Every POM starts with `<modelVersion>4.0.0</modelVersion>`, which tells Maven 3/4 which POM schema to use. It is mandatory. ## How to see it ```bash mvn help:effective-pom mvn help:effective-pom -Doutput=effective-pom.xml ``` This prints the fully-resolved XML — far longer than your file — showing inherited plugins, default repositories, and resolved properties. ## Why it matters The effective POM is the single source of truth for 'what will Maven actually do'. If a plugin runs with a surprising version, a repository you never added is queried, or a property has an unexpected value, the effective POM reveals exactly where it came from.

  • Where does the Super POM physically live?
    It is bundled inside Maven (in the maven-model-builder jar), not in your project; it is the implicit parent of every POM.
  • Name one thing the Super POM provides by default.
    Maven Central as a default repository (in Maven 3), default directory layout (src/main/java, target/), and default lifecycle plugin bindings.

Your pom.xml is a diff; the effective POM is the whole file after the diff is applied on top of all the defaults.

saying these in an interview costs you the question

  • Saying Maven builds directly from the literal pom.xml without merging defaults.
  • Thinking the Super POM is a file in your project you can edit.
  • Confusing effective POM with effective settings (help:effective-settings).

context

open as a page

How do active profiles affect the effective POM, and how do you tell which profiles are active?

level: seniorimportance: must knowfreq 50%

basics

~20 s

Active profiles inject extra dependencies, plugins, properties, or repositories into the computed model, merged on top after inheritance. Profiles can be activated by -P, settings.xml, activeByDefault, OS, JDK, property, or file. Check with mvn help:active-profiles or help:effective-pom.

open as a page

What is the role of <modelVersion>4.0.0</modelVersion> and the Super POM in how a project model is resolved?

level: middleimportance: should knowfreq 45%

basics

~10 s

<modelVersion>4.0.0</modelVersion> declares which POM schema your file uses; it's mandatory. The Super POM is Maven's built-in implicit parent that supplies default repositories, directories, and plugin bindings every project inherits.

open as a page

A teammate's build pulls a dependency version nobody declared, and a plugin runs with unexpected config. How do you diagnose this using the effective POM and related tools?

level: seniorimportance: should knowfreq 35%

basics

~20 s

Generate the effective POM with mvn help:effective-pom to see the fully merged, resolved model and find where the version/config came from. For transitive dependency versions, also use mvn dependency:tree. Check active profiles and settings too.

open as a page

How does Maven merge inherited and management sections into the effective model? Give the precedence rules for inheritance vs. override.

level: seniorimportance: should knowfreq 40%

basics

~20 s

Maven merges from the Super POM up through parents to the child, with child values overriding parent values. Lists (dependencies, plugins) accumulate; scalar values are replaced. Management sections supply defaults the child can use without re-specifying versions.

open as a page