spring的事务管理配置

spring有两种事务配置器,可以使用spring的jdbc事务管理器,也可以使用对hibernate的事务管理器

spring的事务管理配置

第一种 使用Spring JDBC或IBatis进行事务配置(配置文件方式):

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http:// http:// http:// "> <!-- 事务管理器 --> <bean > <!-- 数据源 --> <property ref="dataSource" /> </bean> <!-- 通知 --> <tx:advice transaction-manager="transactionManager"> <tx:attributes> <!-- 传播行为 --> <tx:method propagation="REQUIRED" /> <tx:method propagation="REQUIRED" /> <tx:method propagation="REQUIRED" /> <tx:method propagation="REQUIRED" /> <tx:method propagation="REQUIRED" /> <tx:method propagation="REQUIRED" /> <tx:method propagation="SUPPORTS" read-only="true" /> <tx:method propagation="SUPPORTS" read-only="true" /> <tx:method propagation="SUPPORTS" read-only="true" /> </tx:attributes> </tx:advice> <!-- 切面 --> <aop:config> <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.sso.service.*.*(..))" /> </aop:config> </beans>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zydxxw.html