找不到名为断路器的GatewayFilterFactory

Unable to find GatewayFilterFactory with name CircuitBreaker(找不到名为断路器的GatewayFilterFactory)

本文介绍了找不到名为断路器的GatewayFilterFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

属性文件

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:ValuepediaGateway	argetclasses started by Swapnil.Soni in D:ValuepediaGateway)
[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 

当我试图运行我的Gateway应用程序时,我得到了以下错误,我也尝试过将Spring cloud的版本更改为Hoxton.SR7,但它仍然不起作用。 请提供解决方案。另外,我已经实现了hystrix仪表板,但仅限于加载页面。

推荐答案

与文档https://cloud.spring.io/spring-cloud-gateway/reference/html/#spring-cloud-circuitbreaker-filter-factory所说的不同:

要启用Spring Cloud断路器过滤,您需要将spring-cloud-starter-circuitbreaker-reactor-resilience4j或Spring-cloud-starter-netflix-hystrix放在类路径上。

用户需要同时拥有两个依赖项,才能自动配置以配置SpringCloudCircuitBreakerResilience4JFilterFactory Bean。

ie. 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

javadoc显示:

必须存在的类。

因此,作为@ConditionalOnClass的列表参数列出的任何内容都是在AND关系中,而不是文档声称的是或关系。

这篇关于找不到名为断路器的GatewayFilterFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:找不到名为断路器的GatewayFilterFactory

基础教程推荐