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

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

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

瀏覽:163日期: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
相關文章:
主站蜘蛛池模板: 民丰县| 青铜峡市| 唐海县| 六枝特区| 平塘县| 泗水县| 三都| 桐柏县| 汨罗市| 合肥市| 苏州市| 晋城| 綦江县| 双辽市| 安多县| 扶沟县| 白玉县| 文成县| 本溪市| 香格里拉县| 前郭尔| 青神县| 禄丰县| 盐源县| 易门县| 玉溪市| 正安县| 乌拉特后旗| 疏附县| 丰县| 廉江市| 广西| 寿阳县| 新晃| 汶上县| 盘山县| 大田县| 隆林| 囊谦县| 蓝山县| 永州市|