@EnableHystrix注解与@EnableCircuitBreaker出现在Hystrix服务降级中
@EnableHystrix注解与@EnableCircuitBreaker的区别
我们点开@EnableHystrix注解看源码可以看见@EnableHystrix注解继承了@EnableCircuitBreaker,只是对@EnableCircuitBreaker注解进行了封装
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@EnableCircuitBreaker
public @interface EnableHystrix {
}
而且在Hystrix2.2.10版本中@EnableCircuitBreaker注解已经被淘汰了,所以大胆的用@EnableHystrix注解就行
使用到的依赖
<!--Hystrix-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.2.10.RELEASE</version>
</dependency>