方式一
<!-- 用代理类对 TransactionManager进行组合切面事务管理 -->
<tx:advice id="advice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="find*" propagation="REQUIRED" read-only="true" />
<tx:method name="select*" propagation="REQUIRED" read-only="true" />
<tx:method name="load*" propagation="REQUIRED" read-only="true" />
<tx:method name="get*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!-- 定义切面 -->
<aop:config>
<aop:pointcut expression="execution(*
com.yjm.service.*.*(..))"
id="point" />
<aop:advisor advice-ref="advice" pointcut-ref="point" />
</aop:config>
方式二
<!-- =========================事务管理========================= -->
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="select*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="create*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="remove*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="exit*">PROPAGATION_REQUIRED</prop>
<prop key="copy*">PROPAGATION_REQUIRED</prop>
<prop key="move*">PROPAGATION_REQUIRED</prop>
<prop key="synch*">PROPAGATION_REQUIRED</prop>
<prop key="clean*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="autoproxy"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*Service</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
spring 代理事务管理 都是首先封装一个事务代理类 然后 切入要使用此类规则的service类。
Spring配置代理事务管理配置
发表于:2017-01-09
作者:网络转载
来源:
 相关文章
Spring管理事务配置的五种方式 Spring实战篇系列??Spring事务管理配置 使用spring cloud实现分布式配置管理 SpringMVC配置中易犯的小错误 配置管理规范(配置项标识和配置审计... 配置管理之构建管理- 周排行
- 月排行
- 评论排行
-   iOS VPN开发的配置和管理
-   DCMP:基于etcd的配置管理系统
-   本地多用户下git使用ssh管理配置
-   Nginx配置文件(nginx.conf)配置详解
-   配置文件+虚拟机模板:管理数据中心的...
-   使用etcd+confd管理nginx配置
-   远程登录管理,虚拟网络配置
-   iOS VPN开发的配置和管理
-   配置管理规范(配置项标识和配置审计...
-   管理员必知的六大配置管理工具
-   优雅的项目配置?常用库和版本管理
-   互联网行业的配置管理
-   配置管理之持续集成
-   使用etcd+confd管理nginx配置
-   从软件出发,非功能测试思考总结
-   展望2017,谁是网络技术头牌?
-   C/C++单元测试工具Visual Unit 4 介绍
-   国内外最好用的6款Bug跟踪管理系统
-   性能测试指标评估必读
-   百度软件测试方案模板
-   38张史上最全的IT工程师技能图谱
-   C/C++单元测试工具Visual Unit 4 介绍
-   2019年,你会选哪些安全测试工具?
-   十款Web服务器性能压力测试工具
-   软件测试入门指南:周期、模型和文档化
-   记自动化测试成神学习之路
-   软件测试全景图 -最全的思维导图