久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

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

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

瀏覽:155日期: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
相關文章:
主站蜘蛛池模板: 桓台县| 天全县| 富顺县| 大方县| 灵寿县| 翼城县| 镇江市| 湖州市| 鲜城| 大竹县| 偃师市| 新河县| 邛崃市| 长葛市| 芷江| 莱州市| 兰州市| 黑龙江省| 大安市| 峨眉山市| 密山市| 黑山县| 即墨市| 海丰县| 永靖县| 明溪县| 伊川县| 东乌珠穆沁旗| 军事| 乌苏市| 甘孜| 甘德县| 宜君县| 县级市| 曲松县| 博罗县| 云霄县| 准格尔旗| 尼勒克县| 茶陵县| 忻州市|