File tree Expand file tree Collapse file tree 3 files changed +23
-6
lines changed
eureka-consumer-feign/src/main
java/com/example/demo/feignInterface Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change
1
+ package com .example .demo .feignInterface ;
2
+
3
+ import org .springframework .stereotype .Component ;
4
+
5
+ /**
6
+ * Created by lenovo on 九月
7
+ */
8
+
9
+ @ Component
10
+ public class ClientHystrix implements DcClient {
11
+ @ Override
12
+ public String consumer () {
13
+ return "hystrix" ;
14
+ }
15
+ }
Original file line number Diff line number Diff line change 8
8
*/
9
9
10
10
/**
11
- * 使用@FeignClient注解来指定这个接口所要调用的服务名称,
11
+ * 使用@FeignClient注解。其中的value指定这个接口所要调用的服务名称,fallback指定hystrix的回调类
12
12
* 接口中定义的各个函数使用Spring MVC的注解就可以来绑定服务提供方的REST接口
13
13
*/
14
- @ FeignClient ("eureka-client" )
14
+ @ FeignClient (value = "eureka-client" , fallback = ClientHystrix . class )
15
15
public interface DcClient {
16
-
17
- @ GetMapping ("/dc" )
16
+ @ GetMapping (value = "/dc" )
18
17
String consumer ();
19
18
}
Original file line number Diff line number Diff line change @@ -2,12 +2,15 @@ spring:
2
2
application :
3
3
name : eureka-consumer-feign
4
4
5
-
6
5
server :
7
6
port : 5555
8
7
9
-
10
8
eureka :
11
9
client :
12
10
serviceUrl :
13
11
defaultZone : http://localhost:1111/eureka/
12
+
13
+ # 启动hystrix
14
+ feign :
15
+ hystrix :
16
+ enabled : true
You can’t perform that action at this time.
0 commit comments