Springcloud 使用Finchley.RC2会比Dalston.RC1会有一些不同
1.Maven的引入包会不同,详看:Springcloud从Edgware.SR3升级为Finchley.RC1一些改变
2.若要在feign开启断路器需要在配置文件,根据如下配置:
#开启断路器功能
feign:
hystrix:
enabled: true
3.开启Hystrix 仪表盘会产生一些改变:
在Dalston.RC1如图所示,便可以正常使用 但是如果在Finchley.RC2依旧如此使用,便会产生错误,会报Unable to connect to Command Metric Stream错误, 有两种解决方法:
一、第一种是添加如下代码:
@Bean(name = "hystrixRegistrationBean")
public ServletRegistrationBean getServlet() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
备注:有些还需要在配置文件加上如下配置:
management:
endpoints:
web:
exposure:
include: hystrix.stream
一、第二种是使用新的监控路径,即将http://hystrix-app:port/hystrix.stream改为http://hystrix-app:port/actuator/hystrix.stream,如下图所示: