您的位置:首页 > 其它

事物不回滚

2015-10-12 16:06 489 查看
<?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:jee="http://www.springframework.org/schema/jee"

    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"

    xmlns:aop="http://www.springframework.org/schema/aop"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"
    default-autowire="byName" default-lazy-init="true">

    <!-- 事务配置 -->

    <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*" rollback-for="Exception" />

            <tx:method name="insert*" rollback-for="Exception" />

            <tx:method name="create*" rollback-for="Exception" />

            <tx:method name="edit*" rollback-for="Exception" />

            <tx:method name="update*" rollback-for="Exception" />

            <tx:method name="set*" rollback-for="Exception" />

            <tx:method name="del*" rollback-for="Exception" />

            <tx:method name="remove*" rollback-for="Exception" />

            <tx:method name="clear*" rollback-for="Exception" />

            <tx:method name="move*" rollback-for="Exception" />

            <tx:method name="do*" rollback-for="Exception" />

            <tx:method name="reset*" rollback-for="Exception" />

            <tx:method name="start*" rollback-for="Exception" />

            <tx:method name="add*" rollback-for="Exception" />

            <tx:method name="change*" rollback-for="Exception" />

            <tx:method name="admin*" rollback-for="Exception" />

            <tx:method name="crt*" rollback-for="Exception" />

            <tx:method name="send*" rollback-for="Exception" />

            <tx:method name="cancel*" rollback-for="Exception" />

            <tx:method name="publish*" rollback-for="Exception" />

            <tx:method name="relevance*" rollback-for="Exception" />

            <tx:method name="*" /><!--  目前修改了一下,以后可以考虑该回来 -->

        </tx:attributes>

    </tx:advice>

    <!-- 事务控制拦截器 -->

    <aop:config proxy-target-class="true">

        <aop:advisor pointcut="execution(* *..service..*Service.*(..))"

            advice-ref="txAdvice" />

    </aop:config>

    <!-- 支持 @Transactional 标记  -->

    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />

    

    
</beans>

但事物不回滚一定要抛出异常,
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: