I am trying to create a multi module project that contains two module, core and web. They are both Spring Boot projects that I generated on Spring Initialzer. I setup the Maven POM files but I'm having issues getting it to deploy. However I am confused how the configuration is going to work.
The core module is going to contain the domain object / entities, Spring Data JPA repositories, services, and will be packaged as a JAR. The Web module is going to have Spring Security, the controllers, and the views. It will be packaged as a WAR.
The normal structure of a Spring Boot project looks like the following
/
pom.xml
src/
..main/
....com/
......example/
........app/
..........Application.java
..resources/
....application.properites
I essentially have two of these and two Spring Boot application / configuration / initialization classes.
My questions are
Do the properties have to live in a single configuration file or can I have two application.properities, one the core jar, and one for the WAR?
Can I have the following in my core.jar
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class TimesheetCoreApplication { public static void main(String[] args) { SpringApplication.run(TimesheetCoreApplication.class, args); } }
Along with the following two in my web.war
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TimesheetWebApplication {
public static void main(String[] args) {
SpringApplication.run(TimesheetWebApplication.class, args);
}
}
AND
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(TimesheetWebApplication.class);
}
}
- Since Spring Boot does a lot of auto configuration, will they step over each other with the configuration, either conflicting or overriding one another?
What is the best way to approach this? I would like to leverage Spring Boot if possible.