学习Cloud搭建HystrixDashboard仪表盘中的小坑。由于Hystrix不更新的,所以2.2版本的Spring对它没做好兼容。要自己在生产者的启动类改造:
@SpringBootApplication
@EnableEurekaClient
@EnableDiscoveryClient
@EnableHystrix
@EnableCircuitBreaker
public class CirculateMain {
public static void main(String[] args) {
SpringApplication.run(CirculateMain.class, args);
}
@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;
}
}