-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssm3-spring-tx_xml.template
executable file
·35 lines (30 loc) · 1.52 KB
/
ssm3-spring-tx_xml.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?xml version="1.0" encoding="UTF-8"?>
<!-- @Created with Atom -->
<!-- @author @author@ -->
<!-- @time @now@ -->
<!-- @description -->
<!-- classpath:ssm3/spring-tx.xml -->
<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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<!-- 配置事务 -->
<!--Spring启动加载所有spring的配置文件都能自动找到 -->
<!--1、配置事务管理器 -->
<bean id="tm" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!--2、配置事务切面 -->
<aop:config>
<aop:pointcut expression="execution(* com.sd.packagename.service.*.*(..))" id="txPoint" />
<!--事务增强 -->
<aop:advisor advice-ref="myAdvice" pointcut-ref="txPoint" />
</aop:config>
<!--3、配置事务增强 -->
<tx:advice id="myAdvice" transaction-manager="tm">
<!--事务属性 -->
<tx:attributes>
<tx:method name="*" />
<tx:method name="get*" propagation="SUPPORTS" read-only="true" />
</tx:attributes>
</tx:advice>
</beans>