Skip to content

Commit 64f7374

Browse files
完善fallbackFactory
1 parent 6781fac commit 64f7374

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

eureka-consumer-feign/src/main/java/com/example/demo/feignInterface/user/UserFeignClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* 使用fallbackFactory捕获异常,并进行服务降级。
1313
*/
14-
@FeignClient(value = "eureka-client",fallbackFactory = UserHystrixFallbackFactory.class)
14+
@FeignClient(value = "eureka-client",fallbackFactory = UserFeignClientFallbackFactory.class)
1515
public interface UserFeignClient {
1616

1717
@PostMapping(value = "/user/name/{id}")
+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
*/
1010
@Slf4j
1111
@Component
12-
public class UserHystrixFallbackFactory implements FallbackFactory<UserFeignClient> {
12+
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {
1313

1414
@Override
1515
public UserFeignClient create(Throwable cause) {
1616
System.out.println("====================================》fallback reason was: " + cause.getMessage());
1717

18-
return new UserClientFallbackFactory();
18+
return new UserFeignClientHystrix();
1919
//也可以不写UserClientFallbackFactory类,直接用匿名对象写成以下形式:
2020
// return new UserFeignClient(Integer id) {
2121
// @Override
+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.springframework.stereotype.Component;
77

88
@Component
9-
public class UserClientFallbackFactory implements UserFeignClient {
9+
public class UserFeignClientHystrix implements UserFeignClient {
1010

1111
/**
1212
* 服务熔断

0 commit comments

Comments
 (0)