-
요청한 Bean이 현재 생성 중입니다. 확인할 수 없는 순환 참조가 있습니까? @Component public class AComponent { @Autowired private BComponent bComponent; }
@Component public class BComponent { @Autowired private AComponent aComponent; }
서로를 계속 참조한다 -> 서로 의존성을 가짐 -> 순환 종속성이 생김
해결 방안
1. 구조적으로 해결한다
-> 한 파일 내에서 두 자식 컴포넌트를 사용한 후 부모class에서 사용
2. yml파일에서 순환종속성을 무시
spring: main: allow-circular-references: true
-> 2번 방법보단 1번 방법이 좋다. 구조를 잘 짜야한다.
참고자료
'Spring-Boot > etc.' 카테고리의 다른 글
SpringBoot - CORS 해결방안 (0) 2022.05.09 SpringBoot - JWT ( JSON WEB TOKEN ) - 코드편 (0) 2022.05.09 SpringBoot - JWT ( JSON WEB TOKEN ) - 개념편 (0) 2022.05.09 SpringBoot - Spring Security (0) 2022.05.06 SpringBoot - @ [ 어노테이션 ] (0) 2022.05.04