新版本的问题
按照mall博客的springcloud学习会发现,这毕竟是多年前博主
写的代码了,会有部分代码运行报错,这里是我遇到的以下问题

springboot2.X以后配置方法
springboot版本的问题,版本1.5之前是不需要进行配置的 但是2.x之后是需要对Hystrix进行配置的:
/**
*此配置是为了服务监控而配置,与服务容错本身无关,springcloud升级后的坑
*ServletRegistrationBean因为springboot的默认路径不是"/hystrix.stream",
*只要在自己的项目里配置上下面的servlet就可以了
*/
@Bean
public ServletRegistrationBean getServlet() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
配置修改
原文只说了hystrix-service服务需要开启Actuator的hystrix.stream端点配置
management:
endpoints:
web:
exposure:
include: 'hystrix.stream' #暴露hystrix监控端点
但是hystrix-dashboard也需要配置
hystrix:
dashboard:
proxy-stream-allow-list: "*"
注意!!!

另外http没有s不是https
本文介绍了在学习开源mall项目时遇到的SpringBoot2.x以后Hystrix配置的问题,包括配置方法的变化,如何解决配置错误,以及需要注意的HTTP与HTTPS的区别。同时提供了mall项目的博客学习地址。
2518

被折叠的 条评论
为什么被折叠?



