After switching to Spring Boot, I'm having an issue getting the list of properties available for @Value lookup.
I'm using multiple properties files (classpath:application.context, and /config/applicaton.context for overrrides). That means that reading the classpath:application.context file isn't an option because of the overrides.
classpath:application.properties:
foo.bar.someProp=apple
bar.baz.someProp=peaches
baz.foo.someProp=pumpkin
/config/application.properties:
bar.baz.someProp=cheese
Application.java:
public class Application {
@Value("${foo.bar.someProp}")
private String someProp;
@Value("${bar.baz.someProp}")
private String someProp2;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
...
}
There's no way for me to know that the value of bar.baz.someProp is "cheese" or that baz.foo.someProp exists.
I've seen examples using @ConfigurationProperties but I'd have to know the properties in advance, which I don't.
Ideally I'd just like a map of the properties available to @Value lookups that I've added with the properties files.
I know the management console can show the values of individual properties files, but I can't (not allowed to) activate it and I can't figure out how it's getting the list of properties to mimic the behavior.
Thanks!
Update: 2015-09-08
Ideally there would be a method like this:
public Map<String,Object) getEffectiveProperties() {
....
}
Map<String, Object> allProperties = getEffectiveProperties();
for (Map.Entry<String, Integer> entry : allProperties.entrySet()) {
String key = entry.getKey().toString();
Object value = entry.getValue();
System.out.println("key: " + key + ", value: " + value.toString() );
}
The output would be:
key: foo.bar.someProp, val: apple
key: bar.baz.someProp, val: cheese
key: baz.foo.someProp, val: pumpkin