I have following structure of my application
----
|
|____SpringBootApplicationA
|
|
|___module-1
|___module-2
Each module has its own configuration, For example, module-1 is library that talks to mysql, it has its configuration (connection string, username, password,etc...)
Now I want to represent this configuration in the form of Java POJO in module-1. application.yml and a bean that read configuration and sets the values.
For example
class Module1Config {
private String key1;
private String key2;
// getters & setters
}
application.yml at module-1
key1: val1
key2: val2
now as a consumer of module-1, SpringBootApplicationA will receive module-1's configuration which is what set as default by module-1.
On the consumer side it will have application configuration like this
someKey1: someVal1
someKey2: someVal2
module-1:
key1: overrideVal1
and when initialization happens of module-1's beans, I want the values to be seen as
key1: overrideVal1
key2: val2
How to configure spring boot to respect default values and override them ?
Edit
class AppConfig {
private String key1;
private int key2;
private Module1Config conf;
// getters + setters
}
This is my example application config, as you can see it has some specific to application config and other configs it is leveraging from other modules.
I want conf object to get assigned default set of value from module1 and then whatever application has specified as an override