< bean id ="txManager" class ="org.springframework.jdbc.datasource.DataSourceTransactionManager" >
< property name ="dataSource" ref ="dataSource" />
</ bean >
< aop:config >
< aop:pointcut id ="baseServiceMethods"
expression ="execution(* com.test.service.*.*(..))" />
< aop:advisor advice-ref ="txAdvice"
pointcut-ref ="baseServiceMethods" />
</ aop:config >
< aop:aspectj-autoproxy />
< tx:advice id ="txAdvice" transaction-manager ="txManager" >
< tx:attributes >
< tx:method name ="select*" read-only ="true"/>
< tx:method name ="find*" read-only ="true"/>
< tx:method name ="save*" rollback-for="ServletException,SQLException"/>
< tx:method name ="update*" rollback-for="ServletException,SQLException"/>
< tx:method name ="add*" prollback-for="ServletException,SQLException"/>
< tx:method name ="delete*" rollback-for="ServletException,SQLException" />
</ tx:attributes >
</ tx:advice >
========================================================================
expression ="execution(* com.test.service.*.*(..))
第一个*代表所有的返回值类型
第二个*代表所有的类
第三个*代表类所有方法
最后一个..代表所有的参数
<tx:method/> 相关的属性:
propagation表示事务传播行为,默认为REQUIRED;
isolation表示事务隔离级别,默认为DEFAULT;
read-only表示事务是否只读,默认为false;
rollback-for表示将被触发进行回滚的异常,多个异常以逗号分开;
timeout表示事务超时的时间(以秒为单位),默认为-1;
分享到:
相关推荐
Spring声明式事务配置管理方法
<?xml version="1.0" encoding="UTF-8"?><beansxmlns=...
spring声明式事务配置方法.docx
Spring声明式事务配置模板2.x;提供通用的配置,系统对一些朋友有用。
在 Spring 中,声明式事务处理可以通过配置 TransactionProxyFactoryBean 来实现。TransactionProxyFactoryBean 是一个 FactoryBean,它可以创建一个代理对象,该代理对象可以拦截业务方法的调用,并对事务进行管理...
NULL 博文链接:https://jackyin5918.iteye.com/blog/1921813
在Spring3中配置声明式事务比早期版本显得更加简便。只需要几行配置文件+注解就可以实现面向切面的AOP事务
示例代码 博文链接:https://awaken2012.iteye.com/blog/1728283
Spring使用TransactionProxyFactoryBean声明式事务配置实例
Spring使用XML配置声明式事务 ,具体效果和过程看博文 http://blog.csdn.net/evankaka/article/details/45478007
1. 基于Aspectj实现动态数据源...6. 实现事务内切换数据源(支持原生Spring声明式事务哟,仅此一家),并支持多数据源事务回滚(有了它除了跨服务的事务你需要考虑分布式事务,其他都不需要,极大的减少了系统的复杂程度)
spring3,hibernate4 配置声明式事务管理(annotation方式)
Java高级编程 实验报告 spring 声明事务 实验目的 掌握spring 声明式事务管理配置 实验环境 本实验采用本实验采用的eclipse或者 Myeclpse开发工具。Spring 4.0以上 Jdk1.7以上、oracle/mysql。
Spring_Hibernate使用TransactionInterceptor声明式事务配置 在这篇文章中,我们将探讨使用Spring_Hibernate框架实现声明式事务配置的方法,具体来说,就是使用TransactionInterceptor来管理事务。在Spring框架中,...
Spring ax/aop声明式事务配置实例
Spring 声明式事务处理与多数据源支持 在大部分涉及到数据库操作的项目里面,事务控制、事务处理都是一个无法回避的问题。Spring 框架提供了声明式事务处理机制,使得业务代码中进行事务控制操作起来非常简单。只需...
1.掌握Myeclipse的使用。 2.掌握spring框架和hibernate框架的使用。 3. 掌握整合spring和hibernate的持久化操作编程 4.掌握基于AOP的声明式事务编程...3.配置WEB-INF/applicationContext.xml提供基于AOP的声明式事务