我正在使用Spring Boot配置。我的配置位于git的一个文件夹中。
文件夹结构如下
application.yml
registry.yml
我在application.yml
registry:
server:
port:${REGISTRY_PORT:8761}
host:${REGISTRY_HOST:localhost}
然后我在registry.yml
server:
port: ${registry.server.port}
在Spring Boot启动过程中出现以下异常。我觉得registy.yml
文件已先加载。我可以通过任何方式先加载application.yml文件。
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]