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

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

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

瀏覽:147日期: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
相關文章:
主站蜘蛛池模板: 恩施市| 莆田市| 肇州县| 原阳县| 安福县| 平远县| 巫溪县| 保德县| 秦安县| 美姑县| 石门县| 西城区| 白水县| 邵武市| 崇信县| 闽侯县| 和政县| 元氏县| 澄城县| 苏尼特左旗| 胶州市| 泰州市| 扬州市| 佛学| 永年县| 阿图什市| 和顺县| 西充县| 长寿区| 永春县| 察哈| 新蔡县| 海门市| 昌都县| 凤山县| 高邑县| 普兰店市| 公主岭市| 富裕县| 肥东县| 双流县|