Spring Boot: how do you specify an environment variable that has a dash in application.properties?

I have an application.properties file that looks like this:

 mcl.sso.frontend-url=http://blah.com:9001 mcl.sso.mocking-agent=false 

I am trying to override these two variables from the command line. This should be possible by setting environment variables. This is how I execute the command:

 MCL_SSO_FRONTEND_URL='foobar' MCL_SSO_MOCKING_AGENT='true' ./gradlew run 

However, when I print out the values โ€‹โ€‹of these variables, mcl.sso.mocking-agent is "true" (as expected), but mcl.sso.frontend-url is still equal to " http://blah.com:9001 " ( suddenly). Why doesn't mcl.sso.frontend-url change the value of a property? I can only assume that this has something to do with how Spring translates environment variables into property keys, but I cannot find any specific documentation on this.

+5
source share
1 answer

This is fixed as Spring Boot 1.2.5 . Previously, you had to use the MCL_SSO_FRONTEND-URL (note the dash, which cannot be converted to the underscore).

You can play with bindings using this sample project .

+2
source

All Articles