spring boot support for automatically loading custom yaml file.
Version | Spring Boot Version |
---|---|
0.3.0 | 2.4.x ~ |
0.2.0 | 2.2.x, 2.3.x |
0.1.0 | 2.0.x, 2.1.x |
Spring Boot offers three ways to load custom settings.
- spring.config.location, spring.config.name
- SpringApplicationBuilder
- EnvironmentPostProcessor
[Spring Docs : howto-properties-and-configuration]
There is also this method using Profile
[main module]
spring:
profiles:
include:
- a
- b
- c
[sub module a]
application-a.yml
[sub module b]
application-b.yml
[sub module c]
application-c.yml
[Spring Docs : boot-features-external-config]
but this is cumbersome. when a lot of multi-modules and settings are created, you have to work on them every time.
so i made spring-boot-custom-yaml-importer
so that you can load the settings just by having dependencies.
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.github.kingbbode:spring-boot-custom-yaml-importer:0.3.0'
}
load the yaml file that is matched with resources/config/custom-*.yml
.
write the settings you need for each of your modules here.
|_src
| |_main
| |_resources
| |_config
| | |_ custom-a.yml
| | |_ custom-b.yml
| | |_ custom-c.yml
| |
| |_application.yml
|_app
| |_src
| |_main
| |_resources
| |_config
| | |_custom-a.yml
| |
| |_application.yml
|
|_module-b
| |_src
| |_main
| |_resources
| |_config
| |_custom-b.yml
|_module-c
| |_src
| |_main
| |_resources
| |_config
| |_custom-c.yml