A springboot project, managed by mavan, wants to be modularized.
for example, each module is divided into service, admin-web, front-web, and interface,. Each module is a separate maven project.
service is the lowest level public service, providing business logic processing, database storage, etc.
the other three are control layer, providing page display, interface, etc.
now the question: how to merge two files when each module has its own configuration file application.yml, integration, for example, when starting admin-web, load application.yml in service
the approximate project structure is as follows:
for example, the database configuration file is placed in the yml of service, and the thymeleaf-related configuration of the page is placed in the yml of web. Web relies on service, to use spring.profiles.include in the yml of web to introduce the corresponding yml file in service into the project, and each module configuration file can be independent of each other, but there are some problems:
- service configuration file format must be application-xxx.yml
- configuration values that must be displayed in the yml of web
question: can you provide a @ Configuration, in service that can inject the attribute values of yml in service into the spring container without the need to display the yml file that introduces service in the yml of web? in this case, you only need to rely on service in the pom of web, and the configuration file does not need to be processed.
< hr > Project Code:
https://gitee.com/soft_xiang/.
Database is a public network test library. Delete data at any time, don"t mess around
= 2018.06.19 Update =
the problem of loading the sub-module configuration file has been initially solved. See my answer and recommend the second method
the loading problem of multi-environment configuration files caused by the second method has not been solved for the time being. Please take a look at
= 2018.06.19 update end=