Spring 事务管理配置
<!-- aop事务管理管理器-->
<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<!-- 为连接点指定事物属性-->
<tx:method name="transfer" isolation="DEFAULT"
propagation="REQUIRED" no-rollback-for="MyException"/>
</tx:attributes>
</tx:advice>
<aop:config>
<!-- 切入点配置-->
<aop:pointcut id="point" expression="execution(* *..service.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="point"/>
</aop:config>
带入
<!-- aop事务管理管理器-->
<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<!-- 为连接点指定事物属性-->
<tx:method name="addOrder" isolation="DEFAULT"
propagation="REQUIRED" no-rollback-for="Exception"/>
</tx:attributes>
</tx:advice>
<aop:config>
<!-- 切入点配置-->
<aop:pointcut id="point" expression="execution(* com.test.service.impl.OrderService.addOrder(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="point"/>
</aop:config>
导入相关jar包
<!-- 事务管理-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>
<!-- aop-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>