Spring实例化-Resource leak: 'context' is never closed
来源:互联网 发布:调查问卷数据分析报告 编辑:程序博客网 时间:2024/05/21 10:17
在对spring实例化操作时,ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"),会报警告 Resource leak: 'context' is never closed;对这种警告的处理方法总结如下:
1.改变context 的作用域,提前初始化
public class Test {
private static ApplicationContext context;
public static void main(String[] args) {
context = new ClassPathXmlApplicationContext("Beans.xml");
/.....
}
}
2.强制转换类型,使用close方法
((ConfigurableApplicationContext)ctx).close();
3.初始化时,使用带有close方法的子类
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
阅读全文
0 0
- Spring实例化-Resource leak: 'context' is never closed
- Resource leak: 'context' is never closed
- 警告:Spring ApplicationContext - Resource leak: 'context' is never closed的处理
- 【Spring】在Java使用Spring时的Resource leak: 'applicationContext' is never closed警告
- java出现Resource leak: 'input' is never closed 解决方案
- Java:Resource leak: 'a' is never closed怎么处理?
- eclipse 之中出现了 Resource leak: 'in' is never closed
- java出现Resource leak: 'XXX' is never closed 解决方案
- 【eclipse_bug_001】ApplicationContext Resource leak: 'ctx' is never closed
- Java遇到Resource leak: 'input' is never closed怎么解决
- java出现Resource leak: 'input' is never closed 问题
- eclipse中编写Java程序出现Resource leak: 'input' is never closed解决方法
- ApplicationContext is never closed
- Error creating context 'spring.root': InputStream is null from Resource
- spring.net错误排查 Error creating context 'spring.root': InputStream is null from Resource
- org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl@10cf3d8 is closed。
- org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl@17b9635 is closed
- Spring @Resource实例
- hdu 2647【反向拓扑+前向星】
- 【Python学习系列二十四】scikit-learn库逻辑回归实现唯品会用户购买行为预测
- js 构造函数
- oracle 基本操作
- java8 Comparator
- Spring实例化-Resource leak: 'context' is never closed
- Weec JS Framework(四)
- SonarQube代码质量管理平台安装与使用
- Vue 响应式原理
- 图形数据库简介
- 汉明距离
- HTTP中GET与POST的区别
- NDK相关概念与NDK开发步骤
- js时间戳转正常日期年月日时分秒