How to set default and also use environment variable in application.conf


I want to set a value for one of the configuration variables in application.conf using an environment variable. But if that env variable is missing, I want some value to be configured by default, not an error.
Is it possible? Here is the setting for reference.

test.myframework {
host = ${TEST_HOST_NAME}
}

      

Here if TEST_HOST_NAME, if not, can I default to localhost?

+3


source to share


1 answer


This is documented in the reproduction documentation for Production Configuration :



my.key = defaultvalue
my.key = ${?MY_KEY_ENV}

      

+7


source







All Articles