spring cloud config简介:
架构图:
映射规则:
1.
c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/foobar/dev/master": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
c.itmuch.cloud.ConfigServerApplication : No active profile set, falling back to default profiles: default
application.yml
server:
port: 8081
spring:
cloud:
config:
uri: http://localhost:8080
profile: dev
label: master # 当configserver的后端存储是Git时,默认就是master
application:
name: foobar
解析:
bootstrap.*里面的配置先加载 ——>连接config service, 加载远程配置(git仓库里面的配置) ——>加载application.*里面的配置
解决方法:
新建文件bootstrap.yml
spring:
cloud:
config:
uri: http://localhost:8080
profile: dev
label: master
application:
name: foobar
2.尽量不要把@RefreshScope和@Configuration放在一起使用