@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