Skip to content

Commit 0317503

Browse files
committed
修改eureka-consumer-feign-hystrix,实现hystrix功能
1 parent 78e4b4c commit 0317503

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

2-Dalston版教程示例/eureka-consumer-feign-hystrix/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
<groupId>org.springframework.cloud</groupId>
3333
<artifactId>spring-cloud-starter-feign</artifactId>
3434
</dependency>
35+
<dependency>
36+
<groupId>org.springframework.cloud</groupId>
37+
<artifactId>spring-cloud-starter-hystrix</artifactId>
38+
</dependency>
3539
<dependency>
3640
<groupId>org.springframework.boot</groupId>
3741
<artifactId>spring-boot-starter-web</artifactId>

2-Dalston版教程示例/eureka-consumer-feign-hystrix/src/main/java/com/didispace/DcClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @create 2017/6/24.
99
* @blog http://blog.didispace.com
1010
*/
11-
@FeignClient("eureka-client")
11+
@FeignClient(name = "eureka-client", fallback = DcClientFallback.class)
1212
public interface DcClient {
1313

1414
@GetMapping("/dc")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.didispace;
2+
3+
import org.springframework.stereotype.Component;
4+
5+
/**
6+
* @author 翟永超
7+
* @create 2017/6/24.
8+
* @blog http://blog.didispace.com
9+
*/
10+
@Component
11+
public class DcClientFallback implements DcClient {
12+
13+
@Override
14+
public String consumer() {
15+
return "fallback";
16+
}
17+
}

2-Dalston版教程示例/eureka-consumer-feign-hystrix/src/main/resources/application.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ server.port=2101
33

44
eureka.client.serviceUrl.defaultZone=http://localhost:1001/eureka/
55

6+
feign.hystrix.enabled=true
7+
68
logging.file=${spring.application.name}.log

0 commit comments

Comments
 (0)