user55926
user55926

Reputation: 315

Seperate jar for each module of a multi module maven project

Is it possible to generate separate jar file for each module of my multi module maven project. My project structure

- pom.xml (parent pom)
  |
  |-application
  |
  |-module1
  |
  |-module2

application module has the main() method. Module1 and module 2 are having REST endpoints that have be consumed by the UI. Currently when I run mvn package on application module, I get a big fat jar having all spring boot dependencies plus the dependencies for each module1 and module 2.

Instead I want to have a separate jar file for module1 and module2. So that when I change code in module1, I don't need to deploy that big fat jar everytime, I need to just deploy module1.jar.

Upvotes: 2

Views: 1379

Answers (1)

Essex Boy
Essex Boy

Reputation: 7940

Assuming your application is a Spring Boot Application, this is the way it works.

module1 and module2 should both produce jar files in their target folders.

These jar files a pulled in to the application module as dependencies, then that jar is built as a fat or exploded jar.

Upvotes: 1

Related Questions