A Spring Boot project that contains nested maven projects is called the multi-module project.
In the multi-module project, the parent project works as a container for base maven configurations.A multi-module project is defined by a parent POM referencing one or more submodules.
The parent maven project must contain the packaging type pom that makes the project as an aggregator.
The pom.xml file of the parent project consists the list of all modules, common dependencies, and properties that are inherited by the child projects. The parent pom is located in the project's root directory. The child modules are actual Spring Boot projects that inherit the maven properties from the parent project.
Benefits of Using Multi-Modules:
The significant advantage of using this approach is that we may reduce duplication.
Let's say we have an application which consists of several modules, let it be a front-end module and a back-end module.
Now, we work on both of them and change functionality which affects the two. In that case, without a specialized build tool, we'll have to build both components separately or write a script which would compile the code, run tests and show the results.
Then, after we get even more modules in the project, it will become harder to manage and maintain.
Besides, in the real world, projects may need certain Maven plugins to perform various operations during build lifecycle, share dependencies and profiles or include other BOM projects.
Therefore, when leveraging multi-modules, we can build our application's modules in a single command and if the order matters, Maven will figure this out for us. Also, we can share a vast amount of configuration with other modules.
Parent POM:
Maven supports inheritance in a way that each pom.xml file has the implicit parent POM, it's called Super POM and can be located in the Maven binaries.
These two files are merged by Maven and form the Effective POM.
No comments:
Post a Comment