您的位置:首页 > 编程语言 > Java开发

SpringCloud Finchley.SR1版本 在feign 上使用 hystrix

2018-10-03 17:25 525 查看

SpringCloud Finchley.SR1版本 在feign 上使用 hystrix

一.Feign client 中加入hystrix的 fallaback。
@FeignClient(value = “usercenter-client”,fallback = UserCenteriServiceHystric.class)
public interface UserCenterService {
@GetMapping(“hello”)
String consumer();

}
二 编写 UserCenterServiceHystric.Class

@Component
public class UserCenteriServiceHystric implements UserCenterService {
@Override
public String consumer() {
return “sorry 请求用户中心信息异常”;
}
}

三.启动类中添加注解
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
@EnableAutoConfiguration
@EnableCircuitBreaker
public class OrangeMarketApplication {

public static void main(String[] args) {
new SpringApplicationBuilder(OrangeMarketApplication.class).web(true).run();
}
}

阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: