Marcel Overdijk Marcel Overdijk - 18 days ago 5
YAML Question

Does application.yml support environment variables?

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

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