星空网 > 软件开发 > Java

Springmvc + mybatis + spring 配置,spring事物

今天配置了半天,发现,事物不起效果,主要出现如下错误:

org.mybatis.spring.transaction.SpringManagedTransaction] - [JDBC Connection [com.jolbox.bonecp.ConnectionHandle@120fc40] will not be managed by SpringSqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@47eb1b] was not registered for synchronization because synchronization is not activeClosing non transactional SqlSession

 

后台看到大象的博文才找到答案,意思就是要排出spring servlet对@service注解的扫描,不然会导致事物配置失效,过滤排除@service注解就行了。

Spring MVC启动时的配置文件,包含组件扫描、url映射以及设置freemarker参数,让spring不扫描带有@Service注解的类。为什么要这样设置?因为servlet-context.

 

 

 

1 <!-- 定义控制器注解扫描包路径,控制器注解为 @Controller ,必须排除@Service注解 -->2   <context:component-scan base-package="com.teshehui.product">3     <context:include-filter expression="org.springframework.stereotype.Controller" type="annotation" />4     <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>5   </context:component-scan>

 

 

参考: Spring MVC 3.0.5+Spring 3.0.5+MyBatis3.0.4全注解实例详解(二) 




原标题:Springmvc + mybatis + spring 配置,spring事物

关键词:Spring

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流