找不到名称为 CircuitBreaker 的 GatewayFilterFactory
Posted
技术标签:
【中文标题】找不到名称为 CircuitBreaker 的 GatewayFilterFactory【英文标题】:Unable to find GatewayFilterFactory with name CircuitBreaker 【发布时间】:2021-11-14 16:34:36 【问题描述】:属性文件
server:
port: 8999
eureka:
instance:
hostname: localhost
#Actuator Configuration
management:
endpoints:
web:
exposure:
include: hystrix.stream, health, info
#Hystrix Configuration
hystrix:
command:
fallbackcmd:
execution:
isolation:
thread:
timeoutInMilliseconds: 4000
spring:
application:
name: gateway
cloud:
gateway:
routes:
- id: capability-deck
uri: lb://capability-deck
predicates:
- Path=/capability/**
filters:
- name: CircuitBreaker
args:
name: capability-deck
fallbackuri: forward:/capabilityServiceFallBack
- id: home-page
uri: lb://home-page
predicates:
- Path=/home/**
- id: subscription
uri: lb://subscription
predicates:
- Path=/subscription/**
控制器
package com.valuepedia.gateway.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class FallBackController
@GetMapping("/subscriptionServiceFallBack")
public String userServiceFallBackMethod()
return "Subscription Service is taking longer than Expected." +
" Please try again later";
@GetMapping("/capabilityServiceFallBack")
public String capabilityServiceFallBackMethod()
return "Capability Service is taking longer than Expected." +
" Please try again later";
@GetMapping("/homeServiceFallBack")
public String homeServiceFallBackMethod()
return "Home Service is taking longer than Expected." +
" Please try again later";
主类
package com.valuepedia.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
@EnableEurekaClient
@EnableHystrix
public class GatewayApplication
public static void main(String[] args)
SpringApplication.run(GatewayApplication.class, args);
获取错误信息
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m [2m (v2.5.4)[0;39m
[2m2021-09-21 09:44:08.705[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.valuepedia.gateway.GatewayApplication [0;39m [2m:[0;39m Starting GatewayApplication using Java 15.0.2 on A2568L with PID 7852 (D:\Valuepedia\Gateway\target\classes started by Swapnil.Soni in D:\Valuepedia\Gateway)
[2m2021-09-21 09:44:08.714[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.valuepedia.gateway.GatewayApplication [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2021-09-21 09:44:10.561[0;39m [33m WARN[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.boot.actuate.endpoint.EndpointId [0;39m [2m:[0;39m Endpoint ID 'hystrix.stream' contains invalid characters, please migrate to a valid format.
[2m2021-09-21 09:44:13.646[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.cloud.context.scope.GenericScope [0;39m [2m:[0;39m BeanFactory id=86068429-c6fe-399f-b31b-17fdee65f911
[2m2021-09-21 09:44:14.693[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2m2021-09-21 09:44:14.697[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactorDeferringLoadBalancerFilterConfig' of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactorDeferringLoadBalancerFilterConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2m2021-09-21 09:44:14.701[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'reactorDeferringLoadBalancerExchangeFilterFunction' of type [org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2m2021-09-21 09:44:15.438[0;39m [33m WARN[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.c.sources.URLConfigurationSource [0;39m [2m:[0;39m No URLs will be polled as dynamic configuration sources.
[2m2021-09-21 09:44:15.440[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.c.sources.URLConfigurationSource [0;39m [2m:[0;39m To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
[2m2021-09-21 09:44:15.463[0;39m [33m WARN[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.c.sources.URLConfigurationSource [0;39m [2m:[0;39m No URLs will be polled as dynamic configuration sources.
[2m2021-09-21 09:44:15.463[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.c.sources.URLConfigurationSource [0;39m [2m:[0;39m To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
[2m2021-09-21 09:44:19.020[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [After]
[2m2021-09-21 09:44:19.021[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Before]
[2m2021-09-21 09:44:19.021[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Between]
[2m2021-09-21 09:44:19.021[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Cookie]
[2m2021-09-21 09:44:19.022[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Header]
[2m2021-09-21 09:44:19.022[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Host]
[2m2021-09-21 09:44:19.022[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Method]
[2m2021-09-21 09:44:19.023[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Path]
[2m2021-09-21 09:44:19.025[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Query]
[2m2021-09-21 09:44:19.026[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [ReadBody]
[2m2021-09-21 09:44:19.027[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [RemoteAddr]
[2m2021-09-21 09:44:19.027[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Weight]
[2m2021-09-21 09:44:19.027[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator [0;39m [2m:[0;39m Loaded RoutePredicateFactory [CloudFoundryRouteService]
[2m2021-09-21 09:44:21.669[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.a.e.web.EndpointLinksResolver [0;39m [2m:[0;39m Exposing 3 endpoint(s) beneath base path '/actuator'
[2m2021-09-21 09:44:22.230[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mDiscoveryClientOptionalArgsConfiguration[0;39m [2m:[0;39m Eureka HTTP Client uses RestTemplate.
[2m2021-09-21 09:44:22.424[0;39m [33m WARN[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36miguration$LoadBalancerCaffeineWarnLogger[0;39m [2m:[0;39m Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
[2m2021-09-21 09:44:22.611[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.n.eureka.InstanceInfoFactory [0;39m [2m:[0;39m Setting initial instance status as: STARTING
[2m2021-09-21 09:44:22.800[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Initializing Eureka in region us-east-1
[2m2021-09-21 09:44:22.820[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.d.s.r.aws.ConfigClusterResolver [0;39m [2m:[0;39m Resolving eureka endpoints via configuration
[2m2021-09-21 09:44:22.919[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Disable delta property : false
[2m2021-09-21 09:44:22.919[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Single vip registry refresh property : null
[2m2021-09-21 09:44:22.919[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Force full registry fetch : false
[2m2021-09-21 09:44:22.920[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Application is null : false
[2m2021-09-21 09:44:22.920[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Registered Applications size is zero : true
[2m2021-09-21 09:44:22.920[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Application version is -1: true
[2m2021-09-21 09:44:22.920[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Getting all instance registry info from the eureka server
[2m2021-09-21 09:44:24.054[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m The response status is 200
[2m2021-09-21 09:44:24.067[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Starting heartbeat executor: renew interval is: 30
[2m2021-09-21 09:44:24.081[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.discovery.InstanceInfoReplicator [0;39m [2m:[0;39m InstanceInfoReplicator onDemand update allowed rate per min is 4
[2m2021-09-21 09:44:24.119[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Discovery Client initialized at timestamp 1632197664116 with initial instances count: 0
[2m2021-09-21 09:44:24.126[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.n.e.s.EurekaServiceRegistry [0;39m [2m:[0;39m Registering application GATEWAY with eureka with status UP
[2m2021-09-21 09:44:24.127[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Saw local status change event StatusChangeEvent [timestamp=1632197664127, current=UP, previous=STARTING]
[2m2021-09-21 09:44:24.131[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[nfoReplicator-0][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m DiscoveryClient_GATEWAY/A2568L.corp.ads.valuelabs.net:gateway:8999: registering service...
[2m2021-09-21 09:44:24.201[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[nfoReplicator-0][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m DiscoveryClient_GATEWAY/A2568L.corp.ads.valuelabs.net:gateway:8999 - registration status: 204
[2m2021-09-21 09:44:24.270[0;39m [31mERROR[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.c.gateway.route.CachingRouteLocator [0;39m [2m:[0;39m Refresh routes error !!!
java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name CircuitBreaker
at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.loadGatewayFilters(RouteDefinitionRouteLocator.java:130) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.getFilters(RouteDefinitionRouteLocator.java:176) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.convertToRoute(RouteDefinitionRouteLocator.java:117) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:106) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxFlatMap$FlatMapMain.tryEmitScalar(FluxFlatMap.java:488) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:421) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.drain(FluxMergeSequential.java:432) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.innerComplete(FluxMergeSequential.java:328) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxMergeSequential$MergeSequentialInner.onSubscribe(FluxMergeSequential.java:552) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.Flux.subscribe(Flux.java:8411) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.onNext(FluxMergeSequential.java:237) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:270) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:228) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.onSubscribe(FluxMergeSequential.java:198) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.Flux.subscribe(Flux.java:8411) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.onNext(FluxMergeSequential.java:237) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:270) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:228) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.onSubscribe(FluxMergeSequential.java:198) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.Mono.subscribe(Mono.java:4338) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.Mono.subscribeWith(Mono.java:4453) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.Mono.subscribe(Mono.java:4309) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.Mono.subscribe(Mono.java:4245) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.Mono.subscribe(Mono.java:4217) ~[reactor-core-3.4.9.jar:3.4.9]
at org.springframework.cloud.gateway.route.CachingRouteLocator.onApplicationEvent(CachingRouteLocator.java:81) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
at org.springframework.cloud.gateway.route.CachingRouteLocator.onApplicationEvent(CachingRouteLocator.java:40) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.cloud.gateway.route.RouteRefreshListener.reset(RouteRefreshListener.java:73) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
at org.springframework.cloud.gateway.route.RouteRefreshListener.onApplicationEvent(RouteRefreshListener.java:54) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration.start(EurekaAutoServiceRegistration.java:85) ~[spring-cloud-netflix-eureka-client-3.0.3.jar:3.0.3]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.9.jar:5.3.9]
at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:64) ~[spring-boot-2.5.4.jar:2.5.4]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.4.jar:2.5.4]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.4.jar:2.5.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.4.jar:2.5.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.4.jar:2.5.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.4.jar:2.5.4]
at com.valuepedia.gateway.GatewayApplication.main(GatewayApplication.java:15) ~[classes/:na]
[2m2021-09-21 09:44:24.290[0;39m [33m WARN[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36monfigReactiveWebServerApplicationContext[0;39m [2m:[0;39m Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name CircuitBreaker
[2m2021-09-21 09:44:24.347[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Shutting down DiscoveryClient ...
[2m2021-09-21 09:44:27.370[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Unregistering ...
[2m2021-09-21 09:44:27.384[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m DiscoveryClient_GATEWAY/A2568L.corp.ads.valuelabs.net:gateway:8999 - deregister status: 200
[2m2021-09-21 09:44:27.538[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.netflix.discovery.DiscoveryClient [0;39m [2m:[0;39m Completed shut down of DiscoveryClient
[2m2021-09-21 09:44:27.549[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mConditionEvaluationReportLoggingListener[0;39m [2m:[0;39m
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2m2021-09-21 09:44:27.593[0;39m [31mERROR[0;39m [35m7852[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.boot.SpringApplication [0;39m [2m:[0;39m Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name CircuitBreaker
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.9.jar:5.3.9]
at
当我尝试运行我的网关应用程序时,我收到以下错误,我也尝试将 spring cloud 的版本更改为 Hoxton.SR7,但它仍然无法正常工作。 请提供解决方案。我也实现了 hystrix 仪表板,但只停留在加载页面。
【问题讨论】:
【参考方案1】:根据Spring Cloud CircuitBreaker GatewayFilter Factory 的文档
要启用 Spring Cloud CircuitBreaker 过滤器,您需要 要么放置 spring-cloud-starter-circuitbreaker-reactor-resilience4j 或类路径上的 spring-cloud-starter-netflix-hystrix。
所以,在您的 pom.xml
文件中添加以下依赖项后尝试:
-
spring-cloud-starter-gateway
spring-cloud-starter-circuitbreaker-reactor-resilience4j
spring-cloud-starter-netflix-hystrix
【讨论】:
【参考方案2】:与文档https://cloud.spring.io/spring-cloud-gateway/reference/html/#spring-cloud-circuitbreaker-filter-factory 所说的不同:
要启用 Spring Cloud CircuitBreaker 过滤器,您需要在类路径中放置 spring-cloud-starter-circuitbreaker-reactor-resilience4j 或 spring-cloud-starter-netflix-hystrix。 p>
需要有 BOTH 的依赖项才能自动配置来配置 SpringCloudCircuitBreakerResilience4JFilterFactory bean。
即。 pom.xml:
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-circuitbreaker-reactor-resilience4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
</dependencies>
这是由于这个自动配置类的代码:
@ConditionalOnClass( DispatcherHandler.class,
ReactiveResilience4JAutoConfiguration.class,
HystrixCircuitBreakerAutoConfiguration.class )
public class GatewayCircuitBreakerAutoConfiguration
and @ConditionalOnClass's
javadocs 说:
必须存在的类。
因此,作为@ConditionalOnClass 的列表参数列出的任何内容都属于和关系,而不是文档声称的内容或关系。
【讨论】:
【参考方案3】:检查 spring-boot 版本。 我有同样的问题 。花了很多时间寻找解决方案。 当将 .pom 文件中的 spring-boot 版本从 2.5.5 更改为 2.3.4 Release 并将 spring-cloud.version 从 2020.0.4 更改为 Hoxton.SR8 时,问题已解决
【讨论】:
【参考方案4】:使用这些版本:
parent version=2.4.3
spring-cloud version=2020.0.1
导入依赖:
spring-cloud-starter-circuitbreaker-reactor-resilience4j
jersey-apache-client4
谢谢
【讨论】:
【参考方案5】:添加这些依赖项对我有用。我必须添加
spring-cloud-starter-circuitbreaker-reactor-circuitbreaker
到我的 pom.xml
【讨论】:
【参考方案6】:在你的 pom.xml 文件中添加这个依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.2.10.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-circuitbreaker-reactor-resilience4j -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-circuitbreaker-reactor-resilience4j</artifactId>
<version>2.1.0</version>
</dependency>
【讨论】:
以上是关于找不到名称为 CircuitBreaker 的 GatewayFilterFactory的主要内容,如果未能解决你的问题,请参考以下文章