1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| package com.fuyi.hystrix;
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean;
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
@SpringBootApplication public class Main {
public static void main(String[] args) { SpringApplication.run(Main.class, args); } // SpringBoot加载Servlet有很多种方法,不一定非像此处 @Bean public ServletRegistrationBean servletRegistrationBean() { // ServletName默认值为首字母小写,即myServlet return new ServletRegistrationBean(new HystrixMetricsStreamServlet(), "/hystrix.stream"); } }
|