spring整合mybatis配置 事务管理

Posted draymond

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring整合mybatis配置 事务管理相关的知识,希望对你有一定的参考价值。

分布式的服务端配置

applicationContext-tx.xml

开启注解在service层

 

<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">


<!-- 事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>

<!-- 开启事务控制的注解支持 -->
<tx:annotation-driven transaction-manager="transactionManager"/>

</beans>

对需要添加事务的方法或者类添加 @Transactional 注解

https://www.cnblogs.com/soundcode/p/6478277.html

 


















以上是关于spring整合mybatis配置 事务管理的主要内容,如果未能解决你的问题,请参考以下文章

spring整合mybatis

spring,mybatis 整合 启用tomcat 报错

spring整合mybatis配置 事务管理

spring整合mybatis是如何配置事务的?

mybatis与spring整合

spring整合mybatis的事物管理配置