參考spring applicationContext util

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public final class ApplicationContextUtils implements ApplicationContextAware {
    private static ApplicationContext appContext;
    @Override
    public void setApplicationContext(ApplicationContext arg0)
            throws BeansException {
        appContext = arg0;
    }
              
    public static Object getBean(String args0) {
        return appContext.getBean(args0);
    }
              
    public static ApplicationContext getApplicationContext() {
        return appContext;
    }
}

學習記錄

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章