spring中事务的配置
来源:互联网 发布:快打软件 编辑:程序博客网 时间:2024/04/29 08:13
1.首先在头部(beans)加上头部信息
<beansxmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"></beans>
2.配置事务管理器(transactionManager)
<beanid="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <propertyname="dataSource"ref="dataSource"/></bean>
3.配置事务advice策略(tx:advice)
<tx:adviceid="txAdvice"transaction-manager="transactionManager"> <tx:attributes> <tx:methodname="get*"read-only="true"/> <tx:methodname="find*"read-only="true"/> <tx:methodname="query*"read-only="true"/> <tx:methodname="is*"read-only="true"/> <tx:methodname="*"propagation="REQUIRED"/>(给所有的方法加上事务) </tx:attributes></tx:advice>
4.配置切面管理(aop:config)
<aop:configproxy-target-class="true"><aop:advisorpointcut="execution(* com.kinglo.promotion.service..*Service.*(..))" advice-ref="txAdvice"/></aop:config>
5.Execution的理解
a.步骤d中的execution意思是:
匹配com.kinglo.promotion.service包及其子包中的所有接口名为*Service里所有0个或任意参数的方法
b.第一个*号表示任何权限修饰符(public,private,protected,默认不写).
eg:匹配所有共有方法:execution(public * com.kinglo.promotion.service..*Service.*(..))
c.第二个*号表示匹配任何字符串
d.第三个*号表示任何方法
e.第四个(..)表示0个或任意个参数
- spring中事务的配置
- 在Spring中配置Hibernate的事务
- spring中事务代理的配置
- spring中配置定时触发的事务
- spring的5中事务配置方式
- Spring事务配置的5中方式
- spring事务的五中配置
- Spring事务配置的5中方式
- spring的事务配置5中方式
- Spring事务配置的五中方式
- Spring中事务的配置与使用
- Spring的事务配置
- Spring的事务配置
- Spring的事务配置
- spring的事务配置
- Spring的事务配置
- Spring的事务配置
- Spring的事务配置
- android http get
- pci.h
- JAVA学习笔记(四)substring、System.exit(1)、java.text.SimpleDateFormat、==、equals、StringBuffer、SQl动态查询
- SQLServer常用函数
- 二进制文件的IO操作
- spring中事务的配置
- IOS开发(41)之关于NSString和NSMutableString的retainCount
- 文本查询程序(c++)set,vector,map容器实现
- java.util 类 Hashset用法
- 中语言超酷特性之 --- 便捷定义数据二
- ELF文件格式
- 清空表数据和删除表truncate、delete、drop
- 正则表达式的学习
- 2012九月3号阿里巴巴笔试题目