I have two properties files. Let's say a.properties and b.properties. these file values has been stored in maps created, let say aMap and bMap.
@PropertySource(value={ "classpath:a.properties", "classpath:b.properties"})
Class propFile{
Private Map<String, String> aMap;
Private Map<String, String> bMap;
}
I have to merge these property file into application.properties such that it works same way. Please provide me solution for this.
CodePudding user response:
You will be able to retrieve your properties by annotating your properties class with @Configuration and @ConfigurationProperties:
@Configuration
@ConfigurationProperties(prefix="maps")
public class ConfigProperties {
private Map<String, String> a;
private Map<String, String> b;
// getters and setters
}
The corresponding application.yml
would look as follows:
maps:
a:
key:
test1
b:
key:
test2
Or alternatively with an application.properties
file:
maps.a.key=test1
maps.b.key=test2