Running multiple spring boot cans in one jvm

My project contains several services, each of which is annotated using @SpringBootApplication and can be run on a random port via "gradle bootRun".

Is it possible to create services in banks and run them together in one JVM? It doesn’t matter programmatically or just putting them in a container.

Please show me some instructions if possible. Thanks!

+6
source share
2 answers

This is a bit hacky but can be done. I wrote a blog post about this a while ago: Running multiple Spring applications to load in a single JVM . The basic idea is to run each Spring Boot application in a different class loader (since otherwise resource conflicts would occur).

I personally used it only for testing. I would prefer to use different applications in different docker containers in production. But for testing, this is pretty cool: you can quickly download the application and debug everything ...

+2
source

Yes, you can check this fooobar.com/questions/710796 / ....

However, if the separation of processes and simplicity of the executing user is the main one, I would recommend using a Docker container , each running instance of the container (your applications) will work in its own JVM on the same or distributed host

0
source

All Articles