我有一个运行生产配置文件的@SpringBootApplication和一个spring配置服务器,
{"name":"config-client","profiles":["production"],"label":null,"version":"97611975e6ddb87c7213e18ddbe203ab6ae5485d","state":null,"propertySources":[{"name":"http://git/scm/abm/abm-settings.git/application-production.yml","source":{"my.pretty.property.id":21}}]}
我无法从服务器加载属性my.pretty.property.id(它们总是为null),我正在使用
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "my.pretty.property")
public class MyProperties {
private String id;
}
和我的bootstrap.yml是
spring.cloud:
config:
uri: http://${SERVICE_HOST}/${PROJECT_KEY}-config-server
enabled: false
failFast: true
build.gradle包含这个:
"org.springframework.cloud:spring-cloud-starter-consul-all","org.springframework.cloud:spring-cloud-consul-core","org.springframework.cloud:spring-cloud-starter-hystrix","org.springframework.cloud:spring-cloud-starter-hystrix-dashboard","org.springframework.cloud:spring-cloud-starter-zipkin","org.springframework.cloud:spring-cloud-config-client"
我的客户端应用程序通常是构建和部署的,我缺少什么?
最佳答案
从Spring Cloud Config开始:
原文链接:https://www.f2er.com/spring/431403.htmlThe HTTP service has resources in the form:
/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties
正如您所提到的,您的应用程序正在生产配置文件下运行 – 因此Spring将尝试查找文件:< cloud-config-server-url> /application-production.yml并加载它,除了application.properties.但是您的属性位于application-integration.yml中,并且您不使用集成配置文件.