unknown command property: circuitBreakerEnabled
at com.netflix.hystrix.contrib.javanica.conf.HystrixPropertiesManager.initializeProperties
今天在学习尚硅谷周阳老师的spring cloud 服务熔断
访问http://127.0.0.1:8001/payment/hystrix/circuit_breaker/1 时报错报错信息如下
看了service的熔断配置
//===服务熔断===
@HystrixCommand(fallbackMethod = "circuitBreaker_fallback",commandProperties = {
@HystrixProperty(name = "circuitBreakerEnabled",value = "true"),//是否开启熔断器
@HystrixProperty(name = "circuitBreakerRequestVolumeThreshold",value = "10"),//请求次数
@HystrixProperty(name = "circuitBreakerSleepWindowInMilliseconds",value = "5"),//时间窗口期
@HystrixProperty(name = "circuitBreakerErrorThresholdPercentage",value = "60"),//失败率达到多少后跳闸
})
public String paymentCircuitBreker(Integer id){
if(id<0){
throw new RuntimeException("***id 不能小于0 ***");
}
String serialNumber = IdUtil.simpleUUID();
return "线程:"+Thread.currentThread().getName()+"调用成功,流水号"+serialNumber;
}
是因为哦这里的@HystrixProperty的name都写错了
应该是
@HystrixCommand(fallbackMethod = "circuitBreaker_fallback",commandProperties = {
@HystrixProperty(name = "circuitBreaker.enabled",value = "true"),//是否开启熔断器
@HystrixProperty(name = "circuitBreaker.requestVolumeThreshold",value = "10"),//请求次数
@HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds",value = "5"),//时间窗口期
@HystrixProperty(name = "circuitBreaker.errorThresholdPercentage",value = "60"),//失败率达到多少后跳闸
})
错误解决!!
这里也报同样的错了 后来发现是因为 name = “” 引号中的内容前面有一个空格 ,把空格去掉就好了