2

I am using Spring Boot with a multi module maven project, the structure looks like this

project - project-rest-controller - project-file-adapter - project-library

Where project-rest-controller module contains the @RestController and has a main Spring Boot class to start the embedded tomcat, the controller will receive a POST and create a request and pass it to the project-library module.

Also, project-file-adapter module contains a Spring-Integration file adapter to pull for a file in a directory, read the file and create a request and pass it to the project-library module.

When I run the application using mvn spring-boot:run from within the parent directory, I get an exception with main class should be specified.

It seems that Spring boot allows to specify the main class in the following way

mvn spring-boot:run -Dstart-class=com.blah.App

but I have two main classes.

Should I start two apps?

one from project-rest-controller one from project-file-adapter

This will start two JVMs and that's now what I am trying to do?

user3116783
  • 51
  • 2
  • 4
  • Do you *want* two separate processes? If so, then running two separate Spring Boot apps (via the two separate 'main' classes) is the way to go. But perhaps you don't want or need the overhead of managing two separate services, in which case you could let `project-rest-controller` depend on `project-file-adapter` and the SI piece will run in-process alongside the REST controller. Either approach may be valid depending on non functionals and operational concerns etc. – glytching Jul 12 '17 at 19:25
  • Thanks for the reply! I don't want two processes, it seems the other option is my only option. – user3116783 Jul 12 '17 at 20:17
  • I'm not sure if this is a duplicate of this post, but it seems similar: https://stackoverflow.com/questions/29257409/maven-configuration-with-spring-boot-multi-modules-run-application-in-intell. I would think you can have just 1 main application class, and use a combination of component scan and other annotations to make sure all of your beans are configured and loaded into the application context. – Michael Peacock Jul 12 '17 at 21:35
  • @user3116783 why do you need 2 main classes? – divine Jul 13 '17 at 07:56

0 Answers0