Learning Spring Boot as a replacement for some C/C++ daemons. My goal was to have a single project compiled to a single jar/war. Then use multiple shell scripts to simply start the one I want via command line. I'm using Eclipse Kepler to develop and test the individual Spring Boot applications, and noticed an unwanted behavior. With 4 Spring Boot application classes in the same package, if I start any one of them using an Eclipse launch configuration, all 4 start up in the same Spring Boot. I suspect because all of them have the @SpringBootApplication annotation, and starting one causes Spring Boot to "scan" the current package and sub-packages.
My question, is there a way to have multiple Spring Boot applications in the same package? Do I just create a ControllerApplication with a single @SpringBootApplication and pass in the daemon name I want to start and go from there? Or some other options? Or do I need to create a separate project for each daemon? tia, adym
You could annotate your Spring Boot Application with @ComponentScan's excludeFilters
@ComponentScan(basePackages = "your.package",
excludeFilters = @Filter(SpringBootApplication.class))
You may have many dependency issues from this point on, you can resolve them using the same principle.
This may work inside your IDE, but the generated spring boot jar will only have a single main class attribute. Because of this, even if you find workarounds, I believe you should either :
Take a look at these other answers to launch your spring boot application with multiple spring profiles:
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