I'm migrating from file based .properties file to consul based configuration in my spring application. I'm using spring-cloud-consul. Earlier in my property file I had a property like following
test.key=
In spring application class corresponding field is like this
@Value("${test.key:defaultVal}")
private String testConsul;
In the runtime, the value of testConsul
string is an empty string. But when using the consul, whenever I put key test.key
without a value, in the runtime it gets resolved to a null
.
Is there anyway I can pass an empty string value through consul ?
This is the work around we're using. use a default value which is not exist
${no.such.key:}
Hope this helps.