1, 创建程序,修改pom.xml

       

    <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
            </dependency>

     

    2,启动类

        

    @EnableTurbine
    @SpringBootApplication
    @EnableCircuitBreaker
    @EnableDiscoveryClient
    @EnableHystrixDashboard
    public class ShineHystrixApplication {
         
        
        public static void main(String[] args) {
            SpringApplication.run(ShineHystrixApplication.class, args);
            System.out.print("++++++++++++++++++++++++熔断器中心启动成功!!++++++++++++++++++++++++");
    
        }
    }

     

    3,配置文件

      

    server:
      port: 8768
    spring:
      application:
        name: server-hystrix
      security:
        user:
          name: admin
          password: shine
    eureka:
      client:
        service-url:
          defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@localhost:8761/eureka/
        fetch-registry: true
        register-with-eureka: true
    turbine:
      cluster-name-expression: new String("default")
      combine-host-port: true
    ##要监控的服务,各服务以,分隔 app-config: PlaceSerProFegin,ContentSerProFegin,MemberSerProFegin management: endpoints: web: exposure: include: hystrix.stream

     

     

     

     

    联系QQ:343886028 --加QQ群 145315854