Does application.yml support environment variables?

Marcel Overdijk picture Marcel Overdijk · Apr 12, 2014 · Viewed 87.4k times · Source

I tried using env variables in my application.yml configration like:

spring:
  main:
    show_banner: false

---

spring:
  profiles: production
server:
  address: $OPENSHIFT_DIY_IP
  port: $OPENSHIFT_DIY_PORT

but the env variables are not resolved. Do I have to provide a different notation?

In Rails you can e.g. use <%= ENV['FOOVAR'] %>

The only alternative is to run the app like:

java -jar my.jar --server.address=$OPENSHIFT_DIY_IP --server.port=$OPENSHIFT_DIY_PORT

Answer

Dave Syer picture Dave Syer · Apr 12, 2014

Try ${OPENSHIFT_DIY_PORT} (the usual Spring placeholder notation). See here for docs.