spring事务管理
来源:互联网 发布:券老大淘宝优惠券 编辑:程序博客网 时间:2024/06/06 09:59
1、使用tx管理事务
<aop:config>
<aop:pointcut expression="execution(* com.lq.service.impl.UserServiceImpl.*(..))" id="pc"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="pc"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" rollback-for="Exception" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
2、使用拦截器管理事务
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager" />
<!-- 配置事务属性 -->
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="add*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="delete*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="validate">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="declare*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="*">readOnly</prop>
</props>
</property>
</bean>
<!-- 使用动态代理方式注入事务管理拦截器 -->
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*ServiceImpl</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
- 事务管理之Spring事务管理
- Spring事务管理
- spring事务管理
- Spring事务管理
- Spring事务管理
- Spring事务管理
- Spring事务管理
- Spring事务管理
- Spring 事务管理
- Spring事务管理
- spring 事务管理
- spring 事务管理
- spring 事务管理
- spring事务管理
- Spring 事务管理
- Spring事务管理
- spring事务管理
- spring 事务管理
- 插入排序(c实现)
- 《在macbook上修改MySQL的初始密码》
- 安卓studio打包时出现OOM: GC overhead limit exceeded
- SwiftyJSON的使用
- 翻转二叉树
- spring事务管理
- LeetCode:String to Integer (atoi)没你想的那么简单
- gevent:轻松异步 I/O
- JavaScript sort的使用
- 对齐次矩阵(homogeneous matrix)的理解
- Android M 新的运行时权限开发者需要知道的一切
- 网页输出的种种bug
- 当CollapsingToolbarLayout与ToolBar如何设置Title居中
- 2017-04-09人人网鄙视题后三道原创正解,后续补分析!!!!