spring boot config - property file order

68 Views Asked by At

I am using spring boot config. My configurations are located in one folder in git.

The folder structure is as follows

application.yml
registry.yml

I have the following property defined in application.yml

registry:
 server:
   port:${REGISTRY_PORT:8761}
   host:${REGISTRY_HOST:localhost}

and than i have the following property defined in registry.yml

server:
    port: ${registry.server.port}

I get the following exception during spring boot start up. I feel registy.yml file is loaded first. Any way i can make application.yml file loaded first.

java.lang.IllegalArgumentException: Could not resolve placeholder 'registry.server.port' in value "${registry.server.port}"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172) ~[spring-core-5.1.0.RELEASE.jar:5.1.0.RELEASE]
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.1.0.RELEASE.jar:5.1.0.RELEASE]
    at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237) ~[spring-core-5.1.0.RELEASE.jar:5.1.0.RELEASE]
    at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211) ~[spring-core-5.1.0.RELEASE.jar:5.1.0.RELEASE]
0

There are 0 best solutions below