spring.config.additional-location as environmental variable spring.config.additional-location as environmental variable docker docker

spring.config.additional-location as environmental variable


Value for spring.config.additional-location must be a directory path and not a file path. I'm not sure if this is a bug or a feature, since spring.config.location allows both.

For example inside docker-compose.yml you can set spring.config.additional-location as:

version: '3'    services:      myapp:        build: .        environment:                - "SPRING_CONFIG_ADDITIONAL-LOCATION=file:/opt/myapp/config/"          - "SPRING_PROFILES_ACTIVE=production"...

Then Spring Boot will look up for /opt/myapp/config/application-production.properties file to load properties from.

More about this in Spring Boot Externalized Configuration