标签:覆盖 isolation runtime text ssi 声明 上下 package ota
@Transactional(transactionManager="mainTX", propagation = Propagation.REQUIRED,isolation=Isolation.READ_COMMITTED,rollbackFor=Exception.class)
指定事务管理器
回滚:默认RuntimeException、Error会回滚,其他异常(checked异常)必须声明rollbackFor,notRollbackFor
spring-config.xml
<tx:annotation-driven />
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="mainDataSource" /> <qualifier value="mainTX"/> </bean>
spring-mvc.xml 仅扫描Controller,否则可能覆盖上下文中Service的事务声明
<context:component-scan base-package="com.xxx" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan>
标签:覆盖 isolation runtime text ssi 声明 上下 package ota
原文地址:http://www.cnblogs.com/jintheway/p/5983918.html