国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

Spring獲取ApplicationContext對象工具類的實現方法

瀏覽:171日期:2022-06-07 08:38:58

 Spring獲取ApplicationContext對象工具類的實現方法

(1)實現的工具類:

package com.util; 
 
import org.springframework.context.ApplicationContext; 
import org.springframework.context.support.ClassPathXmlApplicationContext; 
 
final public class ApplicationContextUtil { 
 
  private static ApplicationContext ac=null; 
   
  private ApplicationContextUtil(){ 
     
  } 
   
  static{ 
    ac=new ClassPathXmlApplicationContext("applicationContext.xml"); 
  } 
   
  public static ApplicationContext getApplicationContext(){ 
    //獲得返回的容器對象 
    return ac; 
  } 
   
} 

(2)使用方法:

public static void getByUtil(){ 
    ApplicationContextUtil.getApplicationContext().getBean("userService"); 
  }  

如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

標簽: JSP
相關文章:
主站蜘蛛池模板: 平江县| 乌海市| 南宫市| 府谷县| 枣强县| 台东县| 新平| 织金县| 张掖市| 鹰潭市| 南陵县| 海丰县| 桐梓县| 博罗县| 田阳县| 孝昌县| 拜泉县| 克山县| 晴隆县| 辉县市| 宣化县| 清新县| 太康县| 崇州市| 广灵县| 武威市| 荣成市| 扎赉特旗| 滨州市| 苗栗县| 金溪县| 苍溪县| 弋阳县| 清徐县| 德昌县| 武汉市| 湘西| 泌阳县| 淳化县| 灵武市| 雅安市|