spring+ibatis事务配置
来源:互联网 发布:单片机时钟电路的作用 编辑:程序博客网 时间:2024/05/17 03:00
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd ">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://10.11.0.145:3306/carrefour?characterEncoding=gb2312" />
<property name="username" value="dev01" />
<property name="password" value="123456" />
</bean>
<bean id="sqlClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="configLocation">
<value>classpath:sqlmaps.xml</value>
</property>
</bean>
<!--配置事务管理器-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!--配置哪些方法,什么情况下需要回滚-->
<tx:advice id="serviceAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!--当代理的service层中的方法抛出异常的时候才回滚,必须加rollback-for参数-->
<tx:method name="insert*" propagation="REQUIRED" rollback-for="Throwable"/>
<tx:method name="del*" propagation="REQUIRED" rollback-for="Throwable"/>
<tx:method name="update*" propagation="REQUIRED" rollback-for="Throwable"/>
<!--除了上面标识的方法,其他方法全是只读方法-->
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 配置哪些类的方法需要进行事务管理 -->
<aop:config proxy-target-class="true">
<aop:pointcut id="servicePointcut" expression="execution(* com.crm.service.*.*(..))"/>
<aop:advisor pointcut-ref="servicePointcut" advice-ref="serviceAdvice"/>
</aop:config>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd ">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://10.11.0.145:3306/carrefour?characterEncoding=gb2312" />
<property name="username" value="dev01" />
<property name="password" value="123456" />
</bean>
<bean id="sqlClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="configLocation">
<value>classpath:sqlmaps.xml</value>
</property>
</bean>
<!--配置事务管理器-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!--配置哪些方法,什么情况下需要回滚-->
<tx:advice id="serviceAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!--当代理的service层中的方法抛出异常的时候才回滚,必须加rollback-for参数-->
<tx:method name="insert*" propagation="REQUIRED" rollback-for="Throwable"/>
<tx:method name="del*" propagation="REQUIRED" rollback-for="Throwable"/>
<tx:method name="update*" propagation="REQUIRED" rollback-for="Throwable"/>
<!--除了上面标识的方法,其他方法全是只读方法-->
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 配置哪些类的方法需要进行事务管理 -->
<aop:config proxy-target-class="true">
<aop:pointcut id="servicePointcut" expression="execution(* com.crm.service.*.*(..))"/>
<aop:advisor pointcut-ref="servicePointcut" advice-ref="serviceAdvice"/>
</aop:config>
- spring+ibatis事务配置
- spring ibatis 配置事务
- spring+ibatis事务配置
- spring+ibatis事务配置
- spring+ibatis事务配置
- spring中ibatis事务配置
- Spring数据库及事务配置(ibatis)
- spring ibatis 声明式事务 配置
- Spring管理iBatis事务
- Spring管理iBatis事务
- Spring整合Ibatis事务实现
- spring + ibatis 多数据源事务(分布式事务)管理配置方法(转)
- spring + ibatis 多数据源事务(分布式事务)管理配置方法(转)
- spring 的事务控制 (spring + Ibatis)
- spring+ibatis事务处理配置
- spring+ibatis事务处理配置
- spring+ibatis事务处理配置
- spring+ibatis配置
- 2
- 域名解析文件hosts文件是什么?如何修改hosts文件?
- STL
- easytableview的代码阅读
- (转)OA系统权限管理设计方案
- spring+ibatis事务配置
- debian squeeze 6.0.4安装wine qq2012,ibus中文输入。完美聊天!替代windows!
- hadoop安装---linux5(RHEL5)
- HttpClient最简单使用
- Emgu中遇到的一点问题,无法加载DLL
- Visual C#中实现窗体间的数据传递
- iOS开发中不要使用相对路径
- C#多线程——线程池和回调函数
- 一个httpclient写法