zoukankan      html  css  js  c++  java
  • 异常:java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession

    使用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进行集成.在你的方法调用完毕以后他会自动关闭的。

  • 相关阅读:
    如果再回到从前 备忘录模式
    在NBA我需要翻译 适配器模式
    无尽加班何时休 状态模式
    Linux网络编程学习(六) ----- 管道(第四章)
    Linux网络编程学习(五) ----- 信号(第四章)
    Linux网络编程学习(四) -----守护进程的建立(第三章)
    Linux网络编程学习(三) ----- 进程控制实例(第三章)
    Linux网络编程学习(二) ----- 进程控制(第三章)
    Linux网络编程学习(一) ----- 概论和Linux模型(第一章第二章)
    Linux网络编程学习计划
  • 原文地址:https://www.cnblogs.com/yeahwell/p/4226575.html
Copyright © 2011-2022 走看看