代理模式设计模式

介绍Environment仓储

概念

-{appliation}:配置使用客户端名称

-{profile}:客户端spring.profiles.active配置

-{label}:服务端配置文件版本标识

构建Spring Cloud配置服务器

1.在Configuration class 标记@EnableConfigServer

2.在配置文件目录(基于git)

  1. ccf.properties
  2. ccf-dev.properties
  3. ccf-test.properties
  4. ccf-prod.properties

3.服务端配置版本仓库(本地)

spring.boot.config.server.git.uri= file://ss

##构建Spring Cloud 配置客户端

1
2
3
4
spring.cloud.config.name=chenchangfeng
spring.cloud.config.label=master
spring.cloud.config.uri=http://localhost:8888/
spring.cloud.config.profile=prod

Spring Cloud 分布式配置

动态配置属性Bean

@RefreshScope

健康指标

任意的输出健康指标

AbstractHealthIndicator

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
private static final String NO_MESSAGE = null;
private static final String DEFAULT_MESSAGE = "Health check failed";
private final Log logger;
private final Function<Exception, String> healthCheckFailedMessage;

protected AbstractHealthIndicator() {
this(NO_MESSAGE);
}

protected AbstractHealthIndicator(String healthCheckFailedMessage) {
this.logger = LogFactory.getLog(this.getClass());
this.healthCheckFailedMessage = (ex) -> {
return healthCheckFailedMessage;
};
}

image-20190331221234336

g

w