异常处理Manual close is not allowed over a Spring managed SqlSession

在SpringMVC 配合Mybatis的使用中出现这样一个警告

[org.springframework.beans.factory.support.DisposableBeanAdapter (line-337)] - Invocation of destroy method ‘close’ failed on bean with name ‘sqlSession’: java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession

解决办法:在Spring MVC的配置文件中加入

    <bean id="writableSQLSession" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">
        <constructor-arg index="0" ref="sqlSessionFactory"/>
    bean>

重点是加上scope

你可能感兴趣的:(Java学习,mybatis,异常处理)