Overriding a String List configuration key using Java System properties

February 2, 2016

With Play Framework, you can override configuration keys by specifying them as Java System properties. Example:

activator run -Dsome.key="some.value"

But if you have a String List key, you cannot override it like in the configuration file. Example using the trusted proxies configuration:

activator run -Dplay.http.forwarded.trustedProxies=\["",""\]

You will have this runtime error:

Configuration error\[system properties: play.http.forwarded.trustedProxies has type STRING rather than LIST\]

To avoid this, you have to specify each entry of the list using the entry index:

activator run -Dplay.http.forwarded.trustedProxies.0= -Dplay.http.forwarded.trustedProxies.1=

Note that there are no double quotes around the values. I encountered some issues when using quotes, and it works fine without them.

Nifty tech tag lists from Wouter Beeftink | Page content generated from commit: a47d7c1