spring事务

来源:互联网 发布:windows ntp服务器配置 编辑:程序博客网 时间:2024/06/08 03:03

<!-- 事务相关配置 -->
<tx:advice id="txdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="delete*" propagation="REQUIRED" read-only="false"
  rollback-for="java.lang.Exception" no-rollback-for="java.lang.RuntimeException"/>
<tx:method name="insert*" propagation="REQUIRED" read-only="false"
  rollback-for="java.lang.RuntimeException" />
<tx:method name="update*" propagation="REQUIRED" read-only="false"
  rollback-for="java.lang.Exception" />


<tx:method name="find*" propagation="SUPPORTS"/>
<tx:method name="get*" propagation="SUPPORTS"/>
<tx:method name="select*" propagation="SUPPORTS"/>
</tx:attributes>
</tx:advice>


<aop:config>
<aop:pointcut id="pc" expression="execution(public * org.ssm.services.impl.*.*(..))" /> <!--把事务控制在Service层-->


<aop:advisor pointcut-ref="pc" advice-ref="txdvice" />
</aop:config>


<context:component-scan base-package="org.ssm.services.impl"
        name-generator="org.ssm.overwrite.spring.ServicesNameGenerator"
        use-default-filters="false"
        annotation-config="false">
<context:include-filter type="regex" expression=".*Impl"/>
</context:component-scan>
0 0
原创粉丝点击