【问题标题】:Spring Cloud Gateway Failed to start: Unable to find GatewayFilterFactory with name <blank>Spring Cloud Gateway 启动失败:找不到名称为 <blank> 的 GatewayFilterFactory
【发布时间】:2020-04-20 20:28:37
【问题描述】:

Spring Cloud Gateway 启动失败,报如下异常:

service-gateway      | 2020-01-02 13:44:55.910  INFO 22 --- [           main] c.n.discovery.InstanceInfoReplicator     : InstanceInfoReplicator onDemand update allowed rate per min is 4
service-gateway      | 2020-01-02 13:44:55.915  INFO 22 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1577943895914 with initial instances count: 11
service-gateway      | 2020-01-02 13:44:55.916  INFO 22 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application SERVICE-GATEWAY with eureka with status UP
service-gateway      | 2020-01-02 13:44:55.917  INFO 22 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1577943895917, current=UP, previous=STARTING]
service-gateway      | 2020-01-02 13:44:55.923  INFO 22 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_SERVICE-GATEWAY/a5881e80ffd5:service-gateway:1790: registering service...
service-gateway      | 2020-01-02 13:44:55.991  INFO 22 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_SERVICE-GATEWAY/a5881e80ffd5:service-gateway:1790 - registration status: 204
service-gateway      | 2020-01-02 13:44:56.051  WARN 22 --- [           main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name 
service-gateway      | 2020-01-02 13:44:56.083  INFO 22 --- [           main] com.netflix.discovery.DiscoveryClient    : Shutting down DiscoveryClient ...
service-gateway      | 2020-01-02 13:44:59.085  INFO 22 --- [           main] com.netflix.discovery.DiscoveryClient    : Unregistering ...
service-gateway      | 2020-01-02 13:44:59.093  INFO 22 --- [           main] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_SERVICE-GATEWAY/a5881e80ffd5:service-gateway:1790 - deregister  status: 200
service-gateway      | 2020-01-02 13:44:59.104  INFO 22 --- [           main] com.netflix.discovery.DiscoveryClient    : Completed shut down of DiscoveryClient

【问题讨论】:

    标签: spring spring-boot spring-cloud-gateway


    【解决方案1】:

    在用于创建过滤器的 spring 云网关代码中它说:

    GatewayFilterFactory factory = this.gatewayFilterFactories.get(definition.getName());
                        if (factory == null) {
                            throw new IllegalArgumentException("Unable to find GatewayFilterFactory with name " + definition.getName());
                        }
    

    所以如果创建 gatewayFilterFactory 失败,异常应该给出一条消息:

    “无法找到名称为&lt;some name&gt;的GatewayFilterFactory”,但我的日志中没有这样的内容,只是“无法找到名称为GatewayFilterFactory”。经过2天的研究,我终于发现,我的配置文件有一个错误:

            - id:  api_assets
              uri: lb://BACKEND
              predicates:
                - Path=/api/assets/**
              filters:
                - name: AuditFilter
                -
    

    带有空格的过滤器名称列表

    【讨论】:

      猜你喜欢
      • 2021-01-24
      • 2019-01-09
      • 2020-11-05
      • 1970-01-01
      • 2021-11-14
      • 2023-02-10
      • 2021-03-23
      • 2021-12-09
      • 2018-08-09
      相关资源
      最近更新 更多