spring mvc 声明式事物定义

<bean id="txManger" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
</bean>

<!-- 定义声明式事物规则-->
<tx:advice id="txAdvice" transaction-manager="txManger">
    <tx:attributes>
        <tx:method name="find" propagation="SUPPORTS"/>
        <tx:method name="insert" propagation="REQUIRED"/>
        <tx:method name="update"  propagation="REQUIRED"/>
        <tx:method name="delete"  propagation="REQUIRED"/>
    </tx:attributes>
</tx:advice>

<aop:config>
    <!-- 定义切面-->
    <aop:pointcut id="service" expression="execution(* com.*.*(..))"/>
    <!-- 事物增强切入点组合-->
    <aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
</aop:config>

猜你喜欢

转载自blog.csdn.net/weixin_43113795/article/details/82832597