I am creating a project with spring-boot
.
Spring boot maven structure mandates that it has a parent defined to spring-boot-starter-parent
.
I have a situation where I would like to package my application as a multi-module structure where I define modules which contain functionality related to a geography.
Something like this, each module has a jar packaging,
parent Pom
|
|-----------Core module
|
|-----------India Module
|
|----------Africa Module
|
|--------- Europe Module
Now, I can package my application depending on geography using maven profiles where in India profile only core module and India module are included and packaged.
How can I achieve it using spring boot where my parent is already defined to spring-boot-starter-parent
?
There are two ways one can do it,
use dependencyManagement in your parent pom as in
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<type>pom</type>
<version>1.2.3.RELEASE</version>
<scope>import</scope>
</dependency>
</dependencies>
This is the way I am doing it. The root POM (with pom packaging) has spring boot as parent
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.3.RELEASE</version>
</parent>
the module poms have root pom as parent. The core module POM adds has dependency on other modules. It also has 'spring-boot-maven-plugin' to create the fat jar.
The spring context is started with java -jar Core_xxx.release.jar
Off course if you have organization wise parent POM then first option would be more appropriate.
Right now you can solve that problem using official Spring guidline and create Spring Boot Multi-Module project. Just follow the instruction https://spring.io/guides/gs/multi-module/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With