How to read Environment variables with a Fallback of application.conf in Play?

31 views
Skip to first unread message

kant kodali

unread,
Mar 24, 2017, 4:03:56 PM3/24/17
to Play Framework
Hi,

How to read Environment variables with a Fallback of application.conf in Play?

Right now, I am using "Play.application().configuration()" to read the config application.conf but I would want to see if the Env variables exist first
for the same key in application.conf and if it does I want to read the value from an Environment variable and if not I want to read from application.cong

Thanks!

Greg Methvin

unread,
Mar 24, 2017, 5:08:37 PM3/24/17
to play-framework
You can use the ${?VAR} fallback syntax in config:

key = "default value"
key = ${?VAR} // this line won't do anything if VAR doesn't exist



--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/15d1a1d4-2a38-46da-b50d-d471fd20d51c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Greg Methvin
Tech Lead - Play Framework

Reply all
Reply to author
Forward
0 new messages