Search code examples
scalaplayframeworkconfig

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



I want to set value for one of config variable in application.conf using environment variable. But if this env variable is not present I want to default config to a certain value instead of erring out.
Is this possible? Here is setting for reference.

test.myframework {
host = ${TEST_HOST_NAME}
}

Here if TEST_HOST_NAME if not present can I default host to localhost?


Solution

  • This is described in the play documentation Production Configuration:

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