pom.xml Properties Section
Fast recall
Quick revision
Core answer
properties element defines Maven model values referenced as ${name}. It is useful for a Java release setting, a version shared by several declarations, or a plugin option. A property is simple text model configuration—not a secret store—and a one-use property is optional when it would reduce rather than improve clarity.Understanding of Maven's variable substitution mechanism and best practices for maintaining large POM files with many dependencies
Hardcoding version strings throughout the POM instead of using properties, making bulk updates error-prone and hard to track
Mention that spring-boot-starter-parent uses properties internally for all its version management, and you can override those properties in your own properties section
Interview-ready guide
Interview answer
xml is where you define reusable key-value pairs that you can reference elsewhere in your POM.
The syntax for using a property is dollar-sign-open-brace-property-name-close-brace. The most common use case is centralizing version numbers. version-close-brace in each dependency's version element.
4, you change just one line in the properties section and all dependencies update together. There's no risk of forgetting one and having mismatched versions. Another important use is overriding properties from the spring-boot-starter-parent.
version set to 21 in your properties section. Your value overrides the parent's value. Spring Boot uses this pattern extensively internally — the parent POM has hundreds of properties defining versions for all the libraries it manages.
One mistake freshers make is creating properties for versions used only once. That doesn't add any value — properties are about reuse and consistency. Another mistake is syntax errors, like forgetting the dollar sign or braces, which makes Maven treat it as a literal string instead of a property reference.
pom.xml Properties Section
Direct Answer
The POM properties element defines Maven model values referenced as ${name}. It is useful for a Java release setting, a version shared by several declarations, or a plugin option. A property is simple text model configuration—not a secret store—and a one-use property is optional when it would reduce rather than improve clarity.
Code Example
<properties>
<!-- Override Java version from parent (default is 17) -->
<java.version>21</java.version>
<!-- Custom properties for non-managed dependencies -->
<guava.version>32.1.3-jre</guava.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<testcontainers.version>1.19.3</testcontainers.version>
<!-- Build configuration properties -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>${java.version}</maven.compiler.release>
</properties>
<dependencies>
<!-- Reference property using ${property.name} syntax -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version> <!-- Resolves to 32.1.3-jre -->
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>${testcontainers.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
Common Mistakes & Pitfalls
- Creating unnecessary properties: Defining a property for a version used only once adds complexity without benefit — properties shine when the same version appears in multiple dependencies.
- Incorrect property syntax: Forgetting the dollar sign or curly braces, writing property.name instead of dollar-sign-open-brace-property.name-close-brace, causing Maven to treat it as a literal string.
- Not knowing which properties are overridable: Trying to override a property that's not exposed by the parent POM, or not realizing that java.version in spring-boot-starter-parent is specifically designed to be overridden.
- Property name collisions: Using generic property names like version or name that might conflict with built-in Maven properties or properties from parent POMs — use namespaced names like myproject.guava.version for clarity.
Check your understanding
Answer these without looking back at the article.
- How do you override a Spring Boot managed dependency version?
- What is maven.compiler.source?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.