(quarkus 2.5.4.Final)
With the following .env file:
MY_VAR=
and the following application.properties files:
myapp.foo.bar=${MY_VAR}
and the following constructor
public MyClass(@ConfigProperty(name = "myapp.foo.bar") String bar)
I would like bar
to be an empty string but I have the following error:
Failed to start Quarkus ... Caused by: io.quarkus.runtime.configuration.ConfigurationException: Failed to load config value of type class java.lang.String for: myapp.foo.bar
So far:
- I tried to add the
defaultValue = ""
property to@ConfigProperty
but it does not change anything. - I tried to add a colon:
myapp.foo.bar=${MY_VAR:}
or:null
coupled withdefaultValue
. - I tried to add interpolation (though I could not find docs for that so I'm pasting random stuff):
myapp.foo.bar=${MY_VAR:#{}}
. The app starts but the variable is"}"
and not an empty string.
How can I default to an empty string using an environment variable that is empty or not defined?