spring 事務配置
http://www.aygfsteel.com/robbie/archive/2009/04/05/264003.html全面經典
http://www.ibm.com/developerworks/cn/education/opensource/os-cn-spring-trans/section6.html
1
<!--1、 JDBC一般的事務管理器 begin bean加@Transactional
2
運行期例外回滾,check例外不回滾-->
3
<!-- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">-->
4
<!-- <property name="dataSource" ref="dataSource"></property>-->
5
<!-- </bean>-->
6
<!-- -->
7
<!-- <tx:annotation-driven transaction-manager="transactionManager"/>-->
8
<!-- -->
9
<!-- <bean id="jPersonService" class="cn.itcast.jdbc.service.imple.JPersonServiceBean">-->
10
<!-- <property name="dataSource" ref="dataSource"></property>-->
11
<!-- </bean>-->
12
<!-- JDBC事務管理器 end-->
13
14
15
<!-- 2、聲明性的注解事務管理 begin 加在接口類或方法-->
16
<!-- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">-->
17
<!-- <property name="dataSource" ref="dataSource"></property>-->
18
<!-- </bean>-->
19
<!-- -->
20
<!-- <tx:annotation-driven transaction-manager="transactionManager"/>-->
21
<!-- -->
22
<!-- <bean id="jPersonService2" class="cn.itcast.jdbc.service.imple.JPersonServiceBean2">-->
23
<!-- <property name="dataSource" ref="dataSource"></property>-->
24
<!-- </bean>-->
25
<!-- 2、聲明性的注解事務管理 end-->
26
27
<!-- 聲明性xml配置事務 begin -->
28
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
29
<property name="dataSource" ref="dataSource"></property>
30
</bean>
31
<bean id="jPersonService1" class="cn.itcast.jdbc.service.imple.JPersonServiceBean1">
32
<property name="dataSource" ref="dataSource"></property>
33
</bean>
34
35
<aop:config>
36
<aop:pointcut id="transactionPointcut" expression="execution(* cn.itcast.jdbc.service..*.*(..))" />
37
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut"/>
38
</aop:config>
39
<tx:advice id="txAdvice" transaction-manager="transactionManager">
40
<tx:attributes>
41
<tx:method name="get*" read-only="true" propagation="NOT_SUPPORTED"/>
42
<tx:method name="del*" read-only="true" propagation="REQUIRED"/>
43
<tx:method name="*"/>
44
</tx:attributes>
45
</tx:advice>
46
<!-- xml配置事務 end -->

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

36

37

38

39

40

41

42

43

44

45

46

posted on 2012-03-16 16:53 zhb8015 閱讀(580) 評論(0) 編輯 收藏 所屬分類: ssh