java - Maven Multi Module Spring Boot Project -


i trying create multi module project contains 2 module, core , web. both spring boot projects generated on spring initialzer. setup maven pom files i'm having issues getting deploy. confused how configuration going work.

the core module going contain domain object / entities, spring data jpa repositories, services, , packaged jar. web module going have spring security, controllers, , views. packaged war.

the normal structure of spring boot project looks following

/ pom.xml src/ ..main/ ....com/ ......example/ ........app/ ..........application.java ..resources/ ....application.properites 

i have 2 of these , 2 spring boot application / configuration / initialization classes.

my questions are

  1. do properties have live in single configuration file or can have 2 application.properities, 1 core jar, , 1 war?

  2. can have following in 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 following 2 in 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);     }  } 
  1. since spring boot lot of auto configuration, step on each other configuration, either conflicting or overriding 1 another?

what best way approach this? leverage spring boot if possible.

your design incorrect, if core project going have domain entities, repositories etc. need not boot application. said, going jar.

now make web application boot application dependency on core module jar. can define .properties or .yml in boot application , go.

the problem spring initializer is, gives impression code need reside under single project or module.

this typical project follow applications

  • project-core-module (packaging jar -> domain entities, repositories etc)
  • project-service-module (boot -> configuration, rest interface, security etc)
  • project-system-tests (runs on compile time , certify build)

now bind core , system module service module dependency.


Comments