skip to content

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%

answer

  1. mandatory first declaration
  2. schema grammar selector
  3. implicit parent of all
  4. default dirs + Central
  5. root of inheritance chain

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.

solid answer

~40 s

`<modelVersion>` tells the Maven Model Builder which POM grammar to apply; `4.0.0` has been the value for Maven 2 and 3 (Maven 4 also accepts `4.1.0`). It is required and validated early. The Super POM is the implicit root parent of every project, shipped inside Maven's model-builder. During model resolution Maven starts from the Super POM, applies your inheritance chain, then your project, then active profiles, producing the effective POM. The Super POM is why a brand-new project with a near-empty pom.xml still knows where source lives (`src/main/java`), where output goes (`target/`), which plugins are bound to lifecycle phases, and (in Maven 3) that Central is a repository. Understanding both lets you reason about defaults you never wrote.

code

xml · 6 lines
xml
<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>app</artifactId>
  <version>1.0.0</version>
</project>

go deeper

for a junior

Knows modelVersion is required and the Super POM gives defaults.

for a middle

Explains the Model Builder uses modelVersion to parse, and lists concrete Super POM defaults.

for a senior

Reasons about how Super POM defaults interact with overrides and Maven version differences.

for a principal

Plans migrations across Maven versions (4.0.0 vs 4.1.0, Central relocation) and standardizes defaults via org parent POMs.

## modelVersion Every POM must declare a `<modelVersion>`. It identifies the schema/grammar of the POM document so the **Maven Model Builder** (the component that constructs the effective POM) knows how to parse and validate it. - Maven 2 and Maven 3: `4.0.0`. - Maven 4: introduces `4.1.0` for new features but still reads `4.0.0`. Omitting it is a build error. It is the first line of contract between your file and Maven's parser. ## The Super POM The Super POM is a POM that Maven carries internally and treats as the **implicit parent of every project** — even if you declare no `<parent>`, your project ultimately inherits from it. It is the root of all inheritance chains. What it contributes (defaults you never write): - **Default repository**: in Maven 3 it defines Maven Central. (Maven 4 moves Central out of the Super POM.) - **Default directory layout**: `<sourceDirectory>src/main/java</sourceDirectory>`, `<testSourceDirectory>src/test/java</testSourceDirectory>`, `<outputDirectory>target/classes</outputDirectory>`, `<directory>target</directory>`, default resources under `src/main/resources`. - **Default plugin bindings** for the core lifecycle and baseline versions of common plugins. ## How resolution flows ``` Super POM (implicit root) -> your <parent> chain (if any) -> your project pom.xml -> active profiles injected = effective POM ``` ```xml <project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>app</artifactId> <version>1.0.0</version> </project> ``` Even this minimal file becomes a large effective POM because the Super POM and lifecycle bindings are merged in. ## Why this matters When you ask 'why does Maven look in target/?' or 'why is Central queried?', the answer is the Super POM. The `modelVersion` is what lets the builder interpret your file at all.

  • Does every project literally declare the Super POM as its parent?
    No. It is the IMPLICIT parent — applied automatically even when you declare no <parent> at all.
  • What changed about the Super POM in Maven 4?
    Maven 4 no longer bakes Maven Central into the Super POM and supports modelVersion 4.1.0; defaults were streamlined.

saying these in an interview costs you the question

  • Saying modelVersion is optional or refers to your project's version.
  • Claiming you must add Central as a repository manually in Maven 3 (the Super POM already provides it).
  • Believing the Super POM only applies when you declare a parent.

context