Spring Boot Multi-Module Maven Project
key concepts and configuration examples for setting up a multi-module Maven project using Spring Boot.
flowchart TB
Parent["Parent POM<br/>packaging = pom<br/>dependencyManagement + pluginManagement"]
Parent --> A["service-a<br/>packaging = jar"]
Parent --> B["service-b<br/>packaging = jar"]
Parent --> C["service-c<br/>packaging = jar"]
BOM["Spring Boot BOM<br/>(spring-boot-dependencies)"] -.->|imported into| Parent
Every child inherits versions and plugin config from the parent — that's the entire point of this structure: declare a dependency's version once, in the parent, and every module that uses it stays in lockstep automatically.
Parent POM
Provides consistent versions of dependencies across modules.
A central pom.xml with <packaging>pom</packaging> used to manage modules and shared configuration.
- Declares
<modules>for all child projects. - Centralizes dependency and plugin management.
- Entry point for
mvn installor CI builds.
BOM (Bill of Materials)
do use the Spring Boot parent POM:
If not using the Spring Boot parent, then you must import the Spring BOM manually like this:
This ensures children can declare dependencies without specifying versions.
Dependency Management
Define shared dependency versions in the parent:
Plugin Management
Ensure consistent plugin versions and configuration:
Child Module (e.g., service-a)
Each module has its own pom.xml and inherits from the parent.
Define module-specific dependencies under <dependencies>.
Benefits of This Setup
| Benefit | Why it Matters |
|---|---|
| Version Consistency | Prevents conflicts across modules |
| Central Plugin Control | Reduces repetition and errors |
| Scalable Design | Suitable for microservices or layered apps |
| Easier CI/CD Integration | One entry point for Maven build commands |
This structure allows for clean, maintainable, and scalable Spring Boot applications using Maven.