Spring Boot
parent pom
Maven
dependency management
Java

Spring Boot - parent pom when you already have a parent pom

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

If your Maven project already has a parent POM, you cannot also inherit directly from spring-boot-starter-parent, because Maven supports only one parent. The usual solution is to keep your existing parent and import Spring Boot’s dependency BOM with spring-boot-dependencies instead.

Why the Conflict Exists

Maven allows a single <parent> element:

xml
1<parent>
2    <groupId>com.example</groupId>
3    <artifactId>corporate-parent</artifactId>
4    <version>1.0.0</version>
5</parent>

That means you cannot also do this in the same POM:

xml
1<parent>
2    <groupId>org.springframework.boot</groupId>
3    <artifactId>spring-boot-starter-parent</artifactId>
4    <version>3.3.0</version>
5</parent>

So the real question is not “how do I use both parents,” but “how do I keep my existing parent and still get Spring Boot’s dependency management.”

Use the Spring Boot BOM

Import spring-boot-dependencies in dependencyManagement:

xml
1<project>
2    <parent>
3        <groupId>com.example</groupId>
4        <artifactId>corporate-parent</artifactId>
5        <version>1.0.0</version>
6    </parent>
7
8    <dependencyManagement>
9        <dependencies>
10            <dependency>
11                <groupId>org.springframework.boot</groupId>
12                <artifactId>spring-boot-dependencies</artifactId>
13                <version>3.3.0</version>
14                <type>pom</type>
15                <scope>import</scope>
16            </dependency>
17        </dependencies>
18    </dependencyManagement>
19    
20    <dependencies>
21        <dependency>
22            <groupId>org.springframework.boot</groupId>
23            <artifactId>spring-boot-starter-web</artifactId>
24        </dependency>
25    </dependencies>
26</project>

This gives you Spring Boot’s managed dependency versions while preserving your existing parent hierarchy.

What You Do Not Get Automatically

Using the BOM is not identical to inheriting from spring-boot-starter-parent. The starter parent also provides plugin defaults and some build configuration conveniences.

When you keep your own parent, you may need to configure the Spring Boot Maven plugin yourself:

xml
1<build>
2    <plugins>
3        <plugin>
4            <groupId>org.springframework.boot</groupId>
5            <artifactId>spring-boot-maven-plugin</artifactId>
6        </plugin>
7    </plugins>
8</build>

That is normal. Dependency management and plugin configuration are related, but they are not the same thing.

Why This Pattern Is Common

Many organizations already have a corporate parent POM that controls:

  • repository settings
  • plugin versions
  • code quality rules
  • internal publishing policies

Replacing that parent just to inherit from Spring Boot is often the wrong tradeoff. Importing the Spring Boot BOM lets you adopt Boot’s dependency alignment without breaking the organization’s Maven structure.

Multi-Module Projects

In a multi-module build, a common pattern is:

  1. keep the corporate parent at the top
  2. import Spring Boot BOM in the application module or shared dependency-management layer
  3. configure Spring Boot plugins where needed

This keeps version management centralized and predictable.

Why the BOM Approach Fits Better

Most teams want Boot’s version alignment, not necessarily Boot’s entire parent hierarchy. Importing the BOM delivers that alignment while leaving corporate build rules, repository definitions, and parent-level conventions untouched.

That is usually the least disruptive integration path for established enterprise builds with existing Maven conventions and tooling already in place today generally.

Plugins Still Need a Decision

When you do not inherit from spring-boot-starter-parent, decide explicitly where the Spring Boot Maven plugin configuration belongs. Some teams put it in the application module, while others manage it from a higher-level shared parent through pluginManagement for better consistency.

Common Pitfalls

One common mistake is trying to nest two parents conceptually and expecting Maven to merge them. Maven does not work that way.

Another issue is importing Spring Boot’s BOM and then forgetting to configure the Spring Boot plugin explicitly when the build needs it.

A third pitfall is overriding managed dependency versions casually. Once you import the BOM, custom overrides should be deliberate and rare.

Summary

  • Maven supports only one parent POM.
  • If you already have a parent, do not try to inherit from spring-boot-starter-parent as well.
  • Import spring-boot-dependencies as a BOM in dependencyManagement.
  • Configure the Spring Boot Maven plugin explicitly if needed.
  • This pattern is the standard way to use Spring Boot within an existing Maven parent structure.

Related reading
Course
Intermediate
27 lessons
14 hours
OOD Fundamentals

Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.

View the course
Track 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.

Browse interview questions

All Rights Reserved.