I have an application A which contains code to fetch records from dB and some other functionality. I want to use the same in another project B and use A as dependency. Even if spring boot apps are not recommended to be used as library I have this use case bcs app A is a batch application and doesn’t keep running so no option of rest call. Issue is when I try to create the jar it is created as spring boot jar or if I create a normal jar it doesn’t have the required dependencies and fails at runtime as class not found. It seems dependencies from parent project of A are not included during jar creation. Is there a recommenced way of generating the jar using maven.
Asked
Active
Viewed 451 times
0
-
This answer address similar issue https://stackoverflow.com/a/1729094/2312387 – Sherif Abdelkhaliq Apr 04 '20 at 21:15
-
1Split it into modules. – chrylis -cautiouslyoptimistic- Apr 04 '20 at 21:15
-
1@SherifAbdelkhaliq The Spring Boot Maven plugin handles all of that portion much more cleanly. – chrylis -cautiouslyoptimistic- Apr 04 '20 at 21:16
1 Answers
0
To elaborate on what chrylis said:
Create a project or module C that contains everything that both A and B need. Use it as dependency in A and B.
The easiest way to handle this is to have a multi-module-project with A, B and C, but you can also have three separate projects.

J Fabian Meier
- 33,516
- 10
- 64
- 142