文章詳情頁
Spring獲取ApplicationContext對象工具類的實現(xiàn)方法
瀏覽:124日期:2022-06-07 08:38:58
Spring獲取ApplicationContext對象工具類的實現(xiàn)方法
(1)實現(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ū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
標(biāo)簽:
JSP
相關(guān)文章:
1. SpringMVC生成的驗證碼圖片不顯示問題及解決方法2. springboot使用IDEA遠(yuǎn)程Debug3. Spring 框架簡介4. SpringBoot2.3.0配置JPA的實現(xiàn)示例5. 淺談SpringMVC jsp前臺獲取參數(shù)的方式 EL表達(dá)式6. SpringBoot系列教程之dubbo和Zookeeper集成方法7. Springboot+Vue+shiro實現(xiàn)前后端分離、權(quán)限控制的示例代碼8. 解決springboot的aop切面不起作用問題(失效的排查)9. Spring Boot統(tǒng)一返回體的踩坑記錄10. Vue和SpringBoot之間傳遞時間的方法實現(xiàn)
排行榜
