yalkris yalkris - 4 years ago 111
Scala Question

How to read system variable into a conf file in Play framework

I would read an environment variable like this below

my.key = ${?MY_KEY_ENV}

But how to read a system variable that's passed in via


It is not being resolved in my conf file

Answer Source

assuming your project is managed via SBT. make sure you have the following set in the build file

javaOptions in Global += "-Dmysystem.var=XXX"

and your application.conf file has the following


and now you should be able to be refer the my_key using the below code


tested this in my play app and it is working as expected.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download