关于Spring+mybatis使用@Transactional注解事物没有生效的问题

Posted yyxq

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于Spring+mybatis使用@Transactional注解事物没有生效的问题相关的知识,希望对你有一定的参考价值。

控制台日志信息:

was not registered for synchronization because synchronization is not active JDBC Connection。

Closing non transactional SqlSession [[email protected]19e35973]

出现以上信息说明spring的事物被覆盖掉了,通常是因为在spring.xml中扫描了一次@service注解后,springmvc.xml又重新扫描@service的注解,把事物覆盖掉了。

解决办法:

<context:component-scan base-package="com.zsmonitor">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"></context:exclude-filter>
</context:component-scan>

在springmvc.xml中不扫描@Service注解就可以了

以上是关于关于Spring+mybatis使用@Transactional注解事物没有生效的问题的主要内容,如果未能解决你的问题,请参考以下文章

关于整合spring+mybatis 第二种方式

spring mybatis 关于 basepackage 和 mapperLocations 的通配符匹配实例

关于java-MyBatis-Spring学后笔记

关于Spring+MyBatis的MapperScannerConfigurer无法加载place-holder属性问题分析

mybatis教程2(配置文件)

关于mybatis中type-aliases-package使用的几个问题