SpringMVC事务失效的解决方法
2015-05-17 22:32
501 查看
主要原因就是两个配置文件:
SpringMVC.xml自身加载的时候,注意:
<!-- 自动扫描controller包下的所有类,使其认为spring mvc的控制器 -->
<!-- 加载controller的时候,不加载service,因为此时事物并未生效,若此时加载了service,那么事物无法对service进行拦截 -->
<context:component-scan base-package="org.jeecgframework.web.*,weixin.*">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Service" />
</context:component-scan>
然后配置事务的xml:
<!-- 自动扫描dao和service包(自动注入) -->
<context:component-scan base-package="org.jeecgframework.core.common.dao.*" />
<context:component-scan base-package="org.jeecgframework.core.common.service.*" />
<!-- 加载service,此时要排除要controller,因为controller已经spring-mvc中加载过了 -->
<context:component-scan base-package="org.jeecgframework.web.*,weixin.*">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
修改了事务就可以正确的回滚~~~
SpringMVC.xml自身加载的时候,注意:
<!-- 自动扫描controller包下的所有类,使其认为spring mvc的控制器 -->
<!-- 加载controller的时候,不加载service,因为此时事物并未生效,若此时加载了service,那么事物无法对service进行拦截 -->
<context:component-scan base-package="org.jeecgframework.web.*,weixin.*">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Service" />
</context:component-scan>
然后配置事务的xml:
<!-- 自动扫描dao和service包(自动注入) -->
<context:component-scan base-package="org.jeecgframework.core.common.dao.*" />
<context:component-scan base-package="org.jeecgframework.core.common.service.*" />
<!-- 加载service,此时要排除要controller,因为controller已经spring-mvc中加载过了 -->
<context:component-scan base-package="org.jeecgframework.web.*,weixin.*">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
修改了事务就可以正确的回滚~~~
相关文章推荐
- SpringMVC事务失效的解决方法
- 终于找到全annotation配置springMVC的方法了(事务不失效)
- SpringMVC + Spring + MyBatis 学习笔记:SpringMVC和Spring一同工作的时候,AOP事务管理不起作用的解决方法
- 终于找到全annotation配置springMVC的方法了(事务不失效)
- 终于找到全annotation配置springMVC的方法了(事务不失效)
- 终于找到全annotation配置springMVC的方法了(事务不失效)
- SpringBoot CGLIB AOP解决Spring事务,对象调用自己方法事务失效.
- 终于找到全annotation配置springMVC的方法了(事务不失效)
- [转]终于找到全annotation配置springMVC的方法了(事务不失效)
- 解决spring、springMVC重复扫描导致事务失效的问题
- spring 在有事务的方法上配置自定义日志切面,事务会失效解决方法
- 解决spring、springMVC重复扫描导致事务失效的问题
- spring事务失效解决方法并进行事务的部分回滚
- 【JQUERY】jQuery的选择器在IE8小[checked]失效的解决方法
- 鼠标右键失效的处理解决方法
- 自定义leftBarbuttonItem时,左滑手势会失效,解决左边滑动手势失效方法 ,  怎么停止系统的手势
- SpringMVC中出现" 400 Bad Request "错误(用@ResponseBody处理ajax传过来的json数据转成bean)的解决方法
- Extjs grid panel 滚动条失效的解决方法
- 关于TransactionScope出错:“与基础事务管理器的通信失败”的解决方法(转)
- DBCP数据库连接失效的解决方法(Io 异常:Connection reset)