日期:2014-05-17  浏览次数:21185 次

Spring2.X以AspectJ 式AOP 配置事务
(1)配置:
??? Spring的事务管理是通过AOP代理实现的,其中的事务通知由元数据驱动。代理对象与事务元数据结合产生一个AOP代理,它使用一个PlatformTransactionManager实现,配合TransactionInterceptor,在方法调用前后实施事务。
Java代码 复制代码
  1. <?xml?version="1.0"?encoding="UTF-8"?> ??
  2. ??
  3. <beans?xmlns="http://www.springframework.org/schema/beans"? ??
  4. ????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"? ??
  5. ????xmlns:context="http://www.springframework.org/schema/context"? ??
  6. ????xmlns:aop="http://www.springframework.org/schema/aop"? ??
  7. ????xmlns:tx="http://www.springframework.org/schema/tx"? ??
  8. ????xsi:schemaLocation="http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans-2.5.xsd? ??
  9. ????http://www.springframework.org/schema/context?http://www.springframework.org/schema/context/spring-context-2.5.xsd? ??
  10. ????http://www.springframework.org/schema/tx?http://www.springframework.org/schema/tx/spring-tx-2.5.xsd? ??
  11. ????http://www.springframework.org/schema/aop?http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> ??
  12. ??
  13. ????<description>springApp</description>???? ??
  14. ????<!--?dataSource?for?MySQL?--> ??
  15. ????<bean?id="dataSource"??
  16. ????????class="org.apache.commons.dbcp.BasicDataSource"??
  17. ????????destroy-method="close"> ??
  18. ????????<property?name="driverClassName"??
  19. ????????????value="com.mysql.jdbc.Driver"?/> ??
  20. ????????<property?name="url"??
  21. ????????????value="jdbc:mysql://localhost:3306/springapp"?/> ??
  22. ????????<property?name="username"?value="root"?/> ?? <