Spring獲取ApplicationContext對象工具類的實(shí)現(xiàn)方法
Spring獲取ApplicationContext對象工具類的實(shí)現(xiàn)方法
(1)實(shí)現(xiàn)的工具類:
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");
}
如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
- Spring中BeanFactory和ApplicationContext的作用和區(qū)別(推薦)
- Spring IoC學(xué)習(xí)之ApplicationContext中refresh過程詳解
- SpringBoot獲取ApplicationContext的3種方式
- Spring主配置文件(applicationContext.xml) 導(dǎo)入約束詳解
- Spring通過ApplicationContext主動(dòng)獲取bean的方法講解
- spring中通過ApplicationContext getBean獲取注入對象的方法實(shí)例
- 詳解Spring Boot的GenericApplicationContext使用教程
- Spring MVC之WebApplicationContext_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
- JSP Spring ApplicationContext的國際化支持
- 詳解spring applicationContext.xml 配置文件
- 詳解Spring ApplicationContext加載過程
相關(guān)文章
在JSP中訪問MS SQL Server數(shù)據(jù)庫
在JSP中訪問MS SQL Server數(shù)據(jù)庫...2006-10-10
JSP數(shù)據(jù)交互實(shí)現(xiàn)過程解析
這篇文章主要介紹了JSP數(shù)據(jù)交互實(shí)現(xiàn)過程解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-02-02
jsp從數(shù)據(jù)庫獲取數(shù)據(jù)填充下拉框?qū)崿F(xiàn)二級聯(lián)動(dòng)菜單的方法
這篇文章主要介紹了jsp從數(shù)據(jù)庫獲取數(shù)據(jù)填充下拉框?qū)崿F(xiàn)二級聯(lián)動(dòng)菜單的方法,涉及jsp數(shù)據(jù)庫的操作及聯(lián)動(dòng)菜單的構(gòu)造技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10
JSP連接SQL Server 2000系統(tǒng)配置
JSP連接SQL Server 2000系統(tǒng)配置...2006-10-10
jsp 使用jstl實(shí)現(xiàn)翻頁實(shí)例代碼
這篇文章主要介紹了jsp 使用jstl實(shí)現(xiàn)翻頁實(shí)例代碼,有需要的朋友可以參考一下2013-12-12
JSP實(shí)用教程之簡易文件上傳組件的實(shí)現(xiàn)方法(附源碼)
文件上傳是我們在日常開發(fā)中經(jīng)常遇到的一個(gè)功能,下面這篇文章主要給大家介紹了關(guān)于JSP實(shí)用教程之簡易文件上傳組件的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),需要的朋友們下面來一起看看吧。2017-07-07

