Spring容器上下文的关闭
来源:互联网 发布:星际争霸寻路算法 编辑:程序博客网 时间:2024/05/16 16:57
一、提倡的初始化方法:
1. 在独立应用程序中,获取ApplicationContext:
AbstractApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
1. 在独立应用程序中,获取ApplicationContext:
AbstractApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
context.close();//释放资源
A)ServletContext servletContext = request.getSession().getServletContext();
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
B)String contextpath = "org.springframework.web.context.WebApplicationContext.ROOT";
WebApplicationContext context = request.getSession().getServletContext().getAttribute(contextpath);
二、不提倡的方法:
这种写法不仅仅耗内存,占资源,而且如果数据库连接太多,很容易造成系统运行的缓慢甚至宕机。
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
0 0
- Spring容器上下文的关闭
- Spring 容器(Spring 的上下文)
- 获取spring容器上下文。
- 获得spring容器上下文
- Spring容器优雅的关闭
- Spring MVC上下文父子容器
- spring容器外的组件获得应用上下文的方法
- Spring、SpringMVC及web容器的Context上下文
- 本地Spring容器关闭的时机
- Spring的应用上下文
- Spring源码分析3----Web环境中的SpringMVC(Web容器中的上下文的设计)
- spring上下文和springMVC上下文的关系
- 对SpringMVC上下文容器配置的理解
- Spring framework(3):IoC(1) IoC 容器&上下文对象
- Spring上下文Bean的生命周期
- spring 根上下文和 spring dispatcherServlet 上下文的关系
- spring容器启动事件和关闭事件
- spring容器事件(启动,关闭,刷新...)
- android自动化工具之--Monkey命令介绍
- IOS开发指南学习——视图与控件
- ubuntu下误删除/var/lib/dpkg解决办法
- 视频支持格式
- 关于C++ const 的全面总结
- Spring容器上下文的关闭
- iOS开发之c语言入门教程
- BIOS的基本概念和理解
- Hadoop之一 初识Hadoop
- 算法系列--打印九九乘法表
- 程序猿的一些幽默趣闻 个个经典
- Maven系列--pom.xml 配置详解
- QT对话框中show和exec的区别
- 【C++学习笔记】sizeof()的用法与字节对齐