@SpringBootApplication
@EnableFeignClients//开启open-feign
@EnableHystrix//开启降级熔断服务
public class MyTestApplication1 {
public static void main(String[] args) {
SpringApplication.run(MyTestApplication1.class,args);
}
}
4、在控制层当中调用
@RestController
public class TestController1 {
@Autowired
TestService1 testService1;
@RequestMapping("/myTestBuy1")
public String myTestBuy2(){
return testService1.myTestBuy2();
}
}
5、创建一个类实现服务FeignClient接口
@Component
public class MyHystrix1 implements TestService1 {
@Override
public String myTestBuy2() {
return "调用失败,该服务被熔断――时间:"+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
}
}