主要原因就是兩個設定檔:
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>
修改了事務就可以正確的復原~~~