如何在线程中获取spring 管理的bean
WebApplicationContext webApplication = ContextLoader.getCurrentWebApplicationContext();
this.messageRemindInfoDAO = webApplication.getBean(MessageRemindInfoDAO.class);
implements ApplicationContextAware
private static ApplicationContext context;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}
public static ApplicationContext getContext(){
return context;
}
public static Object getBean(String beanName) {
return context.getBean(beanName);
}