Spring Bean init, destroy 순서
Last updated
Last updated
org.springframework.beans.factory.support.DefaultListableBeanFactory
log level 'DEBUG' 등록
의존성을 기준으로 정렬
Bean init 순서의 역순
The depends-on attribute in the bean definition can specify both an initialization time dependency and, in the case of singleton beans only, a corresponding > destroy time dependency. Dependent beans that define a depends-on relationship with a given bean are destroyed first, prior to the given bean itself being ?> > destroyed. Thus depends-on can also control shutdown order.
@DependsOn
annotation을 사용하면 직접적인 의존관계가 아닌 두 Class의 순서를 조절할 수 있음.
=> 그러나 의존 구조를 개선하여 자연스럽게 초기화되도록 하는 방법이 제일 나음