SpringBoot] [2] [multi-module project share a common configuration file

Preface:

Project has more module, when in fact many of the parameters are the same, each module is configured then be cumbersome and difficult to modify, so it can be independent of public things.

text:

1, create a separate module, stored in public thing

note:

(1) the module configuration file name must be in the form of application-XX, or subsequent configuration unrecognized

(2) the need to remove the module startup class Application.java

(3) test / java to start the test class also needs to be removed

2, in the other module in the configuration file reference

Note: All module packages must start with the same package, that \ src \ main \ java \ com \ backpackname, here should be the same. Otherwise packages under different module might not scan

the Spring: 
  Profiles: 
    the Active: XX 
# application.xml can be referenced with active, in reference to application-YY.xml must include

 3, other xml sharing read

Write xml Path necessary application-XX.yml

mybatis: 
  mapper-locations: classpath:mybatis/**/*.xml

Reference blog:

Shared use IDEA project development springboot multi-module module configuration file reading problem - csonst1017's blog - CSDN blog
https://blog.csdn.net/csonst1017/article/details/85165463

Guess you like

Origin www.cnblogs.com/huashengweilong/p/11879349.html