I have a Spring Boot application which was generated using jhipster, and it works fine. However, I also need to create a second application for some back-office batch jobs, and this application uses most of the spring services of the first application. What I did is create a second main class, which starts a spring boot application. The problem is this also starts the embedded web-server and all the services that are only useful for the web app. I only need the services, persistence and other classes that are not specifically tied to the GUI.
Here are my two main classes (simplified)
The normal spring-boot app:
@ComponentScan @AutoConfigure class Application { public static void main(String[] args) { SpringApplication app = new SpringApplication(Application.class) app.run(args) } } The back-office app:
@ComponentScan @AutoConfigure class BackOfficeApplication { public static void main(String[] args) { SpringApplication app = new SpringApplication(BackOfficeApplication.class) app.run(args) } } What works: My back office application has access to everything that I need. Spring services, beans, etc. The problem: The back office app starts the GUI, preventing me to launch it twice at the same time.
Is there a way to deactivate the launching of the embedded tomcat server? Otherwise, is there a way to load the spring application context in another way that wouldn't start the embedded server ?
Some details: * I don't start the app by using mvn spring-boot:run. I launch the class directly with java (or using eclipse