获取当前的spring容器ApplicationContext
来源:互联网 发布:手绘漫画的软件 编辑:程序博客网 时间:2024/04/28 15:14
方法一:(获取当前的spring容器,任何java类中适用)
ServletContext application = ServletActionContext.getServletContext();
ApplicationContext act = ContextLoader.getCurrentWebApplicationContext();UserService userService = (UserService) act.getBean("userService");
方法二:(重新加载spring容器)
ApplicationContext ac = new FileSystemXmlApplicationContext("applicationContext.xml");
方法三:(通过request或session加载spring容器)
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
0 0
- 获取当前的spring容器ApplicationContext 。
- 获取当前的spring容器ApplicationContext
- 获取当前的spring容器ApplicationContext 。
- ApplicationContext的事件机制&&让Bean获取Spring容器
- 2.4 通过ApplicationContext接口获取Spring容器
- 获取当前系统中的Spring applicationContext.
- 怎么获取Spring的ApplicationContext
- 怎么获取Spring的ApplicationContext
- spring 获取 ApplicationContext的方法
- Spring获取ApplicationContext的方法
- spring的ico容器 ApplicationContext.xml
- Spring容器ApplicationContext
- Spring ApplicationContext 容器 FileSystemXmlApplicationContext
- spring扩展容器-ApplicationContext
- spring容器ApplicationContext
- Spring--IoC--从applicationContext容器中获取对象
- Spring揭秘 学习笔记三 (Spring的IoC容器 ApplicationContext)
- 获取Spring的ApplicationContext的方法
- POI操作Excel常用方法总结
- Linux kernel 3.10内核源码分析--TLB相关--TLB概念、flush、TLB lazy模式
- Hbase
- Lua 的 __index和__newindex的使用
- 一次完整的cstore请求日志(失败,已存在)
- 获取当前的spring容器ApplicationContext
- 解决数据库被其他程序访问,无法获取独占访问权问题
- Dialog无法创建后无法显示的问题
- Linux kernel 3.10内核源码分析--进程退出exit_code
- Struts 2 远程代码执行漏洞(CVE-2016-0785)解决方案
- 敌兵布阵
- hiho 1174 拓扑排序(一)
- SVN 版本控制
- Android开发小技巧系列之避免Toast连续弹出