applicationContext-transaction.xml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <beans xmlns="http://www.springframework.org/schema/beans"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
  3. xmlns:context="http://www.springframework.org/schema/context"
  4. xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  7. http://www.springframework.org/schema/mvc
  8. http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
  9. http://www.springframework.org/schema/context
  10. http://www.springframework.org/schema/context/spring-context-3.2.xsd
  11. http://www.springframework.org/schema/aop
  12. http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
  13. http://www.springframework.org/schema/tx
  14. http://www.springframework.org/schema/tx/spring-tx-3.2.xsd ">
  15. <!-- 事务管理器 对mybatis操作数据库事务控制,spring使用jdbc的事务控制类 -->
  16. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  17. <!-- 数据源 dataSource在applicationContext-dao.xml中配置了 -->
  18. <property name="dataSource" ref="dataSource" />
  19. </bean>
  20. <!-- 通知 -->
  21. <tx:advice id="txAdvice" transaction-manager="transactionManager">
  22. <tx:attributes>
  23. <!-- 传播行为 -->
  24. <tx:method name="save*" propagation="REQUIRED" />
  25. <tx:method name="delete*" propagation="REQUIRED" />
  26. <tx:method name="insert*" propagation="REQUIRED" />
  27. <tx:method name="update*" propagation="REQUIRED" />
  28. <tx:method name="find*" propagation="SUPPORTS" read-only="true" />
  29. <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
  30. <tx:method name="select*" propagation="SUPPORTS" read-only="true" />
  31. </tx:attributes>
  32. </tx:advice>
  33. <!-- aop -->
  34. <aop:config>
  35. <aop:advisor advice-ref="txAdvice"
  36. pointcut="execution(* com.service.impl.*.*(..))" />
  37. </aop:config>
  38. </beans>