码迷,mamicode.com
首页 > 数据库 > 详细

异常:java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession

时间:2015-01-15 17:46:06      阅读:2020      评论:0      收藏:0      [点我收藏+]

标签:

使用mybatis-3.2.2.jar + mybatis-spring-1.2.0.jar集成时,报以下异常:

15:42:48.538 [Thread-1] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy method ‘close‘ on bean with name ‘sqlSession‘
15:42:48.586 [Thread-1] WARN  o.s.b.f.s.DisposableBeanAdapter - Invocation of destroy method ‘close‘ failed on bean with name ‘sqlSession‘
java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession
    at org.mybatis.spring.SqlSessionTemplate.close(SqlSessionTemplate.java:306) ~[mybatis-spring-1.2.0.jar:1.2.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_11]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_11]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_11]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_11]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:327) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:510) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:486) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:740) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:455) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1090) [spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1064) [spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:980) [spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE]
15:42:48.586 [Thread-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean ‘com.pinganfu.common.log.SQLLogInterceptor#1bbf683‘: [sqlSessionFactory]
15:42:48.586 [Thread-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean ‘com.pinganfu.common.pagination.MySql5Dialect#c8211c‘: [com.pinganfu.common.pagination.PaginationInterceptor#76c8cd]
15:42:48.586 [Thread-1] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy method ‘close‘ on bean with name ‘dataSource‘

 

参考这里

http://code.google.com/p/mybatis/issues/detail?id=778

SqlSessionTemplate你不可以手动关闭。SqlSessionTemplate是一个代理类,内部他会为每次请求创建线程安全的sqlsession,并与Spring进行集成.在你的方法调用完毕以后他会自动关闭的。

异常:java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession

标签:

原文地址:http://www.cnblogs.com/yeahwell/p/4226575.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!