<?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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<context:component-scan base-package="service包名"/>
<!--配置事务管理器-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!--注入数据库连接池 dataSource在spring-dao.xml中配置-->
<property name="dataSource" ref="dataSource"/>
</bean>
<!--配置基于注解的声明式事务
默认使用注解来管理事务行为
-->
<tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven>
</beans>spring-service.xml
最新推荐文章于 2024-01-22 16:55:22 发布
本文介绍了一个Spring框架下基于注解的事务管理配置示例。通过定义事务管理器`transactionManager`并结合`DataSourceTransactionManager`类,实现了对数据库操作的事务控制。此外,还展示了如何启用基于注解的声明式事务管理。
1861

被折叠的 条评论
为什么被折叠?



