Spring IOC源码中,声明式事务入口点是如何实现的?
摘要:一、Spring 声明式事务的入口点 对于XML入口点 XML配置定义 <?xml version="1.0" encoding="UTF-
一、Spring 声明式事务的入口点
对于XML入口点
XML配置定义
<?xml version="1.0" encoding="UTF-8"?>
<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
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
https://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
https://www.springframework.org/schema/aop/spring-aop.xsd">
<tx:annotation-driven></tx:annotation-driven>
<!-- dao bean-->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" >
<property name="dataSource" ref = "dataSource"></property>
</bean>
<!-- service bean-->
<bean id="bookService" class="org.yang.learn.spring.tx.BookService" >
<property name="jdbcTemplate" ref="jdbcTemplate"></property>
</bean>
<!-- 数据源 bean-->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" >
<property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property>
<property name="url"
value="jdbc:mysql://192.168.40.171:3306/workflow_test?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false"/>
<property name="username" value="user_dev"></property>
<property name="password" value="dev-sny.com"></property>
</bean>
<!-- 事务管理bean-->
<bean id="transactionManager" class="org.springframework.jdbc.support.JdbcTransactionManager" >
<constructor-arg ref="dataSource"></constructor-arg>
</bean>
<aop:config>
<!--切点配置 -->
<aop:pointcut id="serviceOperation"
expression="execution(* org.yang.learn.spring.tx.BookService.*(..)
