参考地址:http://cloud.spring.io/spring-cloud-netflix/single/spring-cloud-netflix。html # spring-cloud-ribbon
- <李>
<强> IClientConfig
强>
它主要的作用就是装载配置信息,用于初始化客户端和负载均衡器。默认的实现方式是DefaultClientConfigImpl。
public & lt; T>, IClientConfig 设置(IClientConfigKey,,, T 价值); public & lt; T>, T 得到(IClientConfigKey ,,, T defaultValue);
- <李>
<强> DefaultClientConfigImpl 强>
李>它是通过Archaius加载ClientConfig。配置参数可以通过配置文件或系统属性。也可以通过编程的方式实现IClientConfig的加载。
配置文件的配置参数格式:
& lt; clientName>灵活;nameSpace>灵活;propertyName>=& lt; value>
列出正对某个服务的服务名称,如:用户。
名称空间是命名空间,默认是丝带。
如果没有列出,则是对所有的客户都有效。如:
ribbon.ReadTimeout=1000 默认clientConfig,参数:
通过CommonClientConfigKey加载对应的参数类型:
- <李> <强> CommonClientConfigKey 强>
李>
它的作用就是定义各种参数以及对应类型。实现特点:自包含定义常量类。