spring管理事务的配置文件

来源:互联网 发布:c语言多线程实例 编辑:程序博客网 时间:2024/05/14 05:26

个人备忘

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"    xmlns:context="http://www.springframework.org/schema/context"    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:tx="http://www.springframework.org/schema/tx"    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd        http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">    <!-- 发布dubbo服务 -->    <!-- 提供方应用信息,用于计算依赖关系 -->    <dubbo:application name="taotao-manager" />    <!-- 事务管理 -->    <bean id="transactionManager"        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">        <property name="dataSource" ref="dataSource" />    </bean>    <!-- 通知 -->    <tx:advice id="txAdvice" transaction-manager="transactionManager">        <tx:attributes>            <tx:method name="save*" propagation="REQUIRED" />            <tx:method name="add*" propagation="REQUIRED" />            <tx:method name="create*" propagation="REQUIRED" />            <tx:method name="update*" propagation="REQUIRED" />            <tx:method name="do*" propagation="REQUIRED" />            <tx:method name="delete*" propagation="REQUIRED" />            <tx:method name="find*" propagation="SUPPORTS" read-only="true"/>            <tx:method name="select*" propagation="SUPPORTS" read-only="true"/>            <tx:method name="get*" propagation="SUPPORTS" read-only="true"/>        </tx:attributes>    </tx:advice>    <!-- 事务管理的切面 -->    <!--<bean id="userServiceImpl" class="com.zhmhxy.taotao.service.UserServiceImpl"></bean>-->    <aop:config>    <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.zhmhxy.taotao.service.*.*(..))" />    </aop:config></beans>