spring声明事务管理不起作用 不回滚

是因为使用的springMVC和spring对注解的扫描冲突 所以要区别开 springmvc提前注册了service层导致@transaction注解没有起作用


mvc 的只扫描controller组件 注意使用 use-default-filters="false"
<context:component-scan base-package="com.fengzhiyin" use-default-filters="false" >
<context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>

主体的扫描除controller外的所有组件
<context:component-scan base-package="com.fengzhiyin" >
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>

猜你喜欢

转载自yangzhongye.iteye.com/blog/1849497