This article explains how to create a multi-module Spring Boot project with different approaches. We will consider the usage of Spring Initializr, IntelliJ’s new module creation, and how to create a new module in Eclipse.
What Benefits We Achieve in Multi-Module Project
By following the best practices in programming, especially SOLID principles we can achieve clean architecture of the application. One of the principles is Dependency Inversion. This principal advice is to avoid linking for application units without an additional layer. Let us consider in more detail this principal.
SOLID Dependency Inversion
Java 9 Modules
The Future of Modular Java
The Java Module System
How to Create Multi Module Maven Project in IntelliJ
There is a simple approach to creating a new module in IntelliJ IDEA. In the picture below, you can find the menu by following the path: Root > New > Module.
By selecting this menu, the IDE will create a new module. This module will consist of a source folder and a basic pom.xml file.
Let’s consider Spring Boot in Java 11 modules structure. In the following subheading, you can find information in more detail.
Project File Structure
Each time when you create a new module it will consist of the following folders: src > main > java and pom.xml file.
Example of Multi Module Maven Project Spring Boot
In the following file below you can find a basic structure of the main pom. As you can see, the main app consists of sub-modules.