티스토리 뷰

https://medium.com/@eidan.khan659/circular-dependency-in-spring-boot-how-to-detect-and-fix-it-6c8ef2c3174e

 

Circular Dependency in Spring Boot: How to Detect and Fix It?

In Spring Boot, circular dependency occurs when two or more beans depend on each other. This can happen when a bean requires another bean…

medium.com

 

선호하는 방식

Method 2: Setter Injection

Another way to fix circular dependency is to use setter injection instead of constructor injection. With setter injection, Spring Boot will first create the object and then set the required dependencies using the setter method.

 

순환참조가 되는 형태는 최초의 설계보다는 점점 logic들이 쌓이면서, 적절한 권한위임 같은 refactoring이 되지 않아서 생기는 편이 크다고 본다. 물론, refactoring이 힘들수 있는 구조를 만들어 놨을 수도 있다. 어쨌든. 전,후자를 떠나서 구조적인 변경이 필요하다...

'emotional developer > detect-pattern' 카테고리의 다른 글

Spring Security Filter Flow  (0) 2023.05.04
Refactor if/elseif/elseif  (0) 2023.05.04
Rate Limiter  (0) 2023.05.04
공지사항