spring_trans.xml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
  4. xmlns:aop="http://www.springframework.org/schema/aop"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  6. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
  7. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
  8. <!-- 事务管理器 -->
  9. <bean id="transactionManager"
  10. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  11. <!-- 数据源在spring-dao.xml文件中配置的-->
  12. <property name="dataSource" ref="dataSource" />
  13. </bean>
  14. <tx:annotation-driven transaction-manager="transactionManager"/>
  15. <!-- 通知 -->
  16. <tx:advice id="txAdvice" transaction-manager="transactionManager">
  17. <tx:attributes>
  18. <!-- 传播行为 -->
  19. <tx:method name="save*" propagation="REQUIRED" />
  20. <tx:method name="insert*" propagation="REQUIRED" />
  21. <tx:method name="add*" propagation="REQUIRED" />
  22. <tx:method name="create*" propagation="REQUIRED" />
  23. <tx:method name="delete*" propagation="REQUIRED" />
  24. <tx:method name="update*" propagation="REQUIRED" />
  25. <tx:method name="find*" propagation="SUPPORTS" read-only="true" />
  26. <tx:method name="select*" propagation="SUPPORTS" read-only="true" />
  27. <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
  28. </tx:attributes>
  29. </tx:advice>
  30. <!-- 切面 -->
  31. <aop:config>
  32. <aop:advisor advice-ref="txAdvice"
  33. pointcut="execution(* com.ncjt.ch.sm.service.*.*(..))" />
  34. <aop:advisor advice-ref="txAdvice"
  35. pointcut="execution(* com.ncjt.ch.eg.qrcode.service.*.*(..))" />
  36. </aop:config>
  37. </beans>