文章詳情頁
Spring獲取ApplicationContext對象工具類的實現方法
瀏覽:146日期: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
相關文章:
1. 解決springboot bean中大寫的字段返回變成小寫的問題2. Spring事務失效的幾種原因3. spring boot 日志/頁面處理、實體類構建、后臺管理功能的實現4. 淺談SpringMVC jsp前臺獲取參數的方式 EL表達式5. Spring Boot2開發之Spring Boot整合Shiro兩種詳細方法6. Spring-基于Spring使用自定義注解及Aspect實現數據庫切換操作7. springBoot接入阿里云oss的實現步驟8. Spring MVC+ajax進行信息驗證的方法9. SpringMVC+Jquery實現Ajax功能10. Spring+Http請求+HttpClient實現傳參
排行榜
