Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cycle dependency 문제 (Gateway, FeignClient) #1

Closed
progress0407 opened this issue Dec 26, 2023 · 0 comments
Closed

Cycle dependency 문제 (Gateway, FeignClient) #1

progress0407 opened this issue Dec 26, 2023 · 0 comments

Comments

@progress0407
Copy link
Owner

상황

Spring Cloud Gateway에서 FeignClient 적용할때,
앱 실행시 순환 의존으로 실행이 안 되는 문제 발생

The dependencies of some of the beans in the application context form a cycle:

   routeConfig defined in file [C:\dev\5. projects\1. jvm\0. toy\E-Commerce-with-MSA-and-DDD\api-gateway\build\classes\kotlin\main\io\philo\shop\config\RouteConfig.class]
┌─────┐
|  authorizationInceptionFilter defined in file [C:\dev\5. projects\1. jvm\0. toy\E-Commerce-with-MSA-and-DDD\api-gateway\build\classes\kotlin\main\io\philo\shop\filter\AuthorizationInceptionFilter.class]
↑     ↓
|  userRestClientFacade defined in file [C:\dev\5. projects\1. jvm\0. toy\E-Commerce-with-MSA-and-DDD\common\rest-client\build\classes\kotlin\main\io\philo\shop\user\UserRestClientFacade.class]
↑     ↓
|  io.philo.shop.user.UserFeignClient
↑     ↓
|  corsGatewayFilterApplicationListener defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]
↑     ↓
|  routePredicateHandlerMapping defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]
↑     ↓
|  filteringWebHandler defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]

해결 방법

@Lazy 어노테이션 추가

@Component
class AuthorizationInceptionFilter(@Lazy private val userRestClient: UserRestClientFacade) : GlobalFilter, Ordered { ... }

참고

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant