How to deploy multi-module Spring Boot Maven project?

465 Views Asked by At

Assume I have a Spring Boot Project Structure like below:

Main-Module
|
|    +- Module-A
|        +- src
|            +- java
|                +- ApplicationA.java
|            +- resources
|                +- static
|                  +- css
|                  +- js
|                +- templates
|                    +- index.html
|        +- pom.xml
|
|    +- Module-B
|        +- src
|            +- java
|                +- ApplicationB.java  
|            +- resources
|                +- static
|                  +- css
|                  +- js
|                +- templates
|                    +- index.html
|        +- pom.xml
|
|    +- Module-C
|        +- src
|            +- java
|                +- ApplicationC.java 
|            +- resources
|                +- static
|                  +- css
|                  +- js
|                +- templates
|                    +- index.html 
|        +- pom.xml
|
|    +- pom.xml

ApplicationA.java, ApplicationB.java, ApplicationC.java run on different port separately, such like 8080, 8200, 8300.

Also, Module-B has dependency of Module-A.

May I ask how do I deploy this kind of multi-module project, each module has it's own "@SpringBootApplication"?

Will it be deployed into a single jar? After running the jar, all the "@SpringBootApplication" will be started?

I tried to execute maven package command, and I got 3 Jars (3 sub-modules).

Then I don't know how to deploy them, such like deploy to AWS.

Also, there are not much answers found related to this problem.

1

There are 1 best solutions below

0
krishnan On

Perhaps you would need to deploy each applications seperately. You can deploy the applications individually or depending on how you want it.

There are multiple offering from AWS to deploy our java applications here are a few among them.

  1. If you are looking for a solution with containerized approach : AWS Fargate
  2. For a managed solution for running java apps using Tomcat Platform / Java SE Platform : Elastic Beanstalk
  3. Additionally you may explore EC2, if you are looking to manage the instance by your own.

Here's a offical spring guide for deploying your spring boot application on AWS.