采用AOP配置声明式事务有5种方式,下面只说关于采用TransactionInterceptor事务拦截器的方式,配置程序如下:
transactionManager的:
- < 豆 的id = “dataSource的” 类= “org.apache.commons.dbcp.BasicDataSource” 破坏法= “关闭” />
- < bean id = "transactionManager" class = "org.springframework.jdbc.datasource.DataSourceTransactionManager" >
- < 属性 名= “dataSource的” 参考= “的dataSource” />
- </ 豆>
的TransactionInterceptor:
- < bean id = "transactionInterceptor" class = "org.springframework.transaction.interceptor.TransactionInterceptor" >
- < 属性 名= “transactionManager的” REF = “transactionManager的” />
- < 属性 名= “transactionAttributes” >
- < 道具>
- < 托 键= “添加*” > PROPAGATION_REQUIRED </ 道具>
- < 托 键= “德尔*” > PROPAGATION_REQUIRED </ 道具>
- < 托 键= “更新*” > PROPAGATION_REQUIRED </ 道具>
- < 托 键= “查询*” > 只读</ 道具>
- < 托 键= “得到*” > 只读</ 道具>
- < 托 键= “找到*” > 只读</ 道具>
- < 托 键= “检查*” > PROPAGATION_REQUIRED </ 道具>
- < 托 键= “操作*” > PROPAGATION_REQUIRED </ 道具>
- < 托 键= “批量*” > PROPAGATION_REQUIRED </ 道具>
- < 托 键= “部署*” > PROPAGATION_REQUIRED </ 道具>
- < 托 键= “EXEC *” > PROPAGATION_REQUIRED </ 道具>
- </ 道具>
- </ 财产>
- </ 豆>
自动代理的BeanNameAutoProxyCreator:
- < bean的 类= “org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator” >
- < 属性 名= “beanNames” >
- < - !所有以BUSImpl命名的豆-ID都会被事务拦截 - >