二. 快速入门
feign.hystrix.enabled=true
@FeignClient(value = "hello-service", fallback = HelloServiceHystrix.class)
public interface HelloService {
@GetMapping("/hello")
String sayHello(@RequestParam(value = "name") String name);
}
接着实现上面fallback指定的类:
@Component
public class HelloServiceHystrix implements HelloService {
@Override
public String sayHello(String name) {
return "hello " + name + ", error!";
}
}
http://localhost:8765/hello?name=Jack
Hello Jack. I am from port:8762
http://localhost:8765/hello?name=Jack
hello Jack, error!
https://github.com/lingd3/SpringCloudLearning/tree/master/chapter6