given the following sample class
@ConfigurationProperties("myapp")
public class MyProps {
MyProps(Map<String, String> propertymap) {
System.out.println("propertymap = " + propertymap);
}
}
and following application.yml
myapp:
propertymap:
a: b
c: d
Everything works fine.
Now I try to do property resolving with the propertymap
in my yaml and I wonder whether spring boot supports that? I change the yaml file to the following:
somecloud:
someprefix:
propertymap:
a: b
b: c
myapp:
propertymap:
${somecloud.someprefix.propertymap}
The application start fails with:
Failed to bind properties under 'myapp.propertymap' to java.util.Map<java.lang.String, java.lang.String>:
Property: myapp.propertymap
Value: "${somecloud.someprefix.propertymap}"
Origin: class path resource [application.yml] - 9:5
Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, java.lang.String>]
Basically, I try to resolve the property which normale works like a gem, but in this case the property itself is a map. Does spring boot support "map property resolving" in any way and am I doing it wrong? Or is it simply not supported?
Background: I am working in a cloud environment (Cloud Foundy) and the properties are given from the outside. The properties will be prefixed with some cloud stuff (vcap.services) which I want to "rewrite" in my application. Yes, I could use the cloud prefix ("vcap.services....") directly in my application code, but that would make my application less portable which I want to prevent.
Any ideas?