错误信息
java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name Hystrix
at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.loadGatewayFilters(RouteDefinitionRouteLocator.java:130) ~[spring-cloud-gateway-server-3.1.1.jar:3.1.1]
at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.getFilters(RouteDefinitionRouteLocator.java:176) ~[spring-cloud-gateway-server-3.1.1.jar:3.1.1]
at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.convertToRoute(RouteDefinitionRouteLocator.java:117) ~[spring-cloud-gateway-server-3.1.1.jar:3.1.1]
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:106) ~[reactor-core-3.4.16.jar:3.4.16]
at reactor.core.publisher.FluxFlatMap$FlatMapMain.tryEmitScalar(FluxFlatMap.java:488) ~[reactor-core-3.4.16.jar:3.4.16]
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:421) ~[reactor-core-3.4.16.jar:3.4.16]
at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.drain(FluxMergeSequential
翻译的意思:没找到HystrixGatewayFilterFactory。我想可能是没找到对应的这个类,我去查看加载的jar包中class文件,发现在springcloud gateway3.1.1的版本不再提供HystrixGatewayFilterFactory这个类(而这个类在gateway2.5.5版本提供)。
以下配置也没用了:
filters:
- name: Hystrix
args:
name: fallbackcmd
fallbackUri: forward:/defFallback
解决办法
自定义过滤器整合hystrix:重新实现一遍HystrixGatewayFilterFactory