服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

spring 2.0 的事务自动处理

 <aop:config>
        <!--<aop:advisor id="usermanagertx" advice-ref="usermanagertxadvice" pointcut="execution(* *..service.usermanager.*(..))" order="0"/>-->       
        <!--<aop:advisor id="usermanagersecurity" advice-ref="usersecurityadvice" pointcut="execution(* *..service.usermanager.saveuser(..))" order="1"/>-->
        <aop:advisor id="managertx" advice-ref="txadvice" pointcut="execution(* *..service.*manager.*(..)) || execution(* *..service.*service.*(..))" order="0"/>
    </aop:config>
   
    <tx:advice id="txadvice">
        <tx:attributes>
            <tx:method name="get*" propagation="supports" read-only="true"/>
            <tx:method name="save*" propagation="required"/>
            <tx:method name="update*" propagation="required"/>
            <tx:method name="remove*" propagation="required"/>
            <tx:method name="*" propagation="supports"/>
        </tx:attributes>
    </tx:advice>

 <!-- transaction manager for a single jdbc datasource -->
    <bean id="transactionmanager" class="org.springframework.jdbc.datasource.datasourcetransactionmanager">
        <property name="datasource" ref="datasource"/>
    </bean>

扫描关注微信公众号