spring 부팅 컨 텍스트 가 져 오기
1624 단어 springboot 지식
@Component
public class ApplicationContextProvider implements ApplicationContextAware {
private static ApplicationContext context;
public static ApplicationContext getApplicationContext() {
return context;
}
@Override
public void setApplicationContext(ApplicationContext ctx) {
context = ctx;
}
}
applicationContextAware 를 실현 하 는 모든 bean 은 spring 용기 에 초기 화 된 후에 setapplicationContext 를 실행 하여 spring 의 컨 텍스트 를 가 져 옵 니 다.