Sandy
Sandy

Reputation: 2613

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?

Upvotes: 22

Views: 12543

Answers (1)

rethab
rethab

Reputation: 8413

This is described in the play documentation Production Configuration:

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

Upvotes: 27

Related Questions