@Transactional聲明式事務配置:spring
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>express
<!-- 聲明式事務配置 -->
<tx:annotation-driven transaction-manager="transactionManager" />app
----------------------------------------------------------------分割線---------------------------------------------------------------------------------------------------------------------------------spa
添加以上配置後,在類上聲明瞭@Transactional(以下圖),可是在action層中調用MenuHeadInsMapServiceImpl類的方法A,發現方法A並無進入事務。.net
解決辦法:component
1.在spring的配置文件applicationContext.xml中,掃描包時排除Controller:xml
<context:component-scan base-package="com.cg.*.*">blog
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>事務
2.在springMVC配置文件servlet.xml中,掃描包時排除Service: servlet
<context:component-scan base-package="com.cg.*.*">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>
主要是參考了這篇文章:http://blog.csdn.net/z69183787/article/details/37819627