小编ker*_*nel的帖子

Feign Client 与 Spring Cloud GatewayFilter 导致循环依赖

在某些检查期间,我需要向网关过滤器中的微服务发出请求。\n当我在 GatewayFilter(my SecurityFilter.java) 类中定义 Feign 类时,会出现以下错误。\n我该如何解决这种情况。

\n

错误:

\n
Description:\n\nThe dependencies of some of the beans in the application context form a cycle:\n\n\xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n|  securityFilter defined in file [/target/classes/com/example/SecurityFilter.class]\n\xe2\x86\x91     \xe2\x86\x93\n|  cachedCompositeRouteLocator defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]\n\xe2\x86\x91     \xe2\x86\x93\n|  routeDefinitionRouteLocator defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x98\n\n\nAction:\n\nDespite circular references being allowed, the dependency cycle between beans could not be broken. Update your application to remove the dependency cycle.\n
Run Code Online (Sandbox Code Playgroud)\n

网关过滤器类

\n
@Component\npublic class SecurityFilter implements GatewayFilterFactory<SecurityFilter.Config> {\n\n    private final UserApi userApi;\n\n    public SecurityFilter(UserApi …
Run Code Online (Sandbox Code Playgroud)

spring-security spring-boot spring-cloud-feign spring-cloud-gateway openfeign

1
推荐指数
1
解决办法
1792
查看次数