春如何基于xml实现声明式事务控制

  

<强>一、pom.xml

        & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比;   & lt;项目xmlns=" http://maven.apache.org/POM/4.0.0 "   xmlns: xsi=" http://www.w3.org/2001/XMLSchema-instance "   xsi: schemaLocation=" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”比;   & lt; modelVersion> 4.0.0      & lt; groupId> org.example   & lt; artifactId> A02spring   & lt; version> 1.0 -snapshot      & lt; dependencies>   & lt; !——https://mvnrepository.com/artifact/org.springframework/spring-context-->   & lt; dependency>   & lt; groupId> org.springframework   & lt; artifactId> spring-context   & lt; version> 5.2.8.RELEASE   & lt;/dependency>   & lt; !——https://mvnrepository.com/artifact/org.springframework/spring-context-->   & lt; dependency>   & lt; groupId> org.springframework   & lt; artifactId> spring-jdbc   & lt; version> 5.2.8.RELEASE   & lt;/dependency>   & lt; !——https://mvnrepository.com/artifact/org.springframework/spring-context-->   & lt; dependency>   & lt; groupId> org.springframework   & lt; artifactId> spring-tx   & lt; version> 5.2.8.RELEASE   & lt;/dependency>   & lt; !——https://mvnrepository.com/artifact/org.aspectj/aspectjweaver——比;   & lt; dependency>   & lt; groupId> org.aspectj   & lt; artifactId> aspectjweaver   & lt; version> 1.9.6   & lt;/dependency>   & lt; !——https://mvnrepository.com/artifact/org.springframework/spring-context-->   & lt; dependency>   & lt; groupId> mysql   & lt; artifactId> mysql-connector-java   & lt; version> 8.0.11   & lt;/dependency>   & lt; !——https://mvnrepository.com/artifact/org.projectlombok/lombok——比;   & lt; dependency>   & lt; groupId> org.projectlombok   & lt; artifactId> lombok   & lt; version> 1.18.12   & lt; scope> provided   & lt;/dependency>   & lt; !——https://mvnrepository.com/artifact/org.springframework/spring-test——比;   & lt; dependency>   & lt; groupId> org.springframework   & lt; artifactId> spring-test   & lt; version> 5.2.8.RELEASE   & lt; scope> test   & lt;/dependency>   & lt; !——https://mvnrepository.com/artifact/junit/junit——比;   & lt; dependency>   & lt; groupId> junit   & lt; artifactId> junit   & lt; version> 4.13 & lt;/version>   & lt; scope> test   & lt;/dependency>   & lt;/dependencies>      & lt; build>   & lt; plugins>   & lt; plugin>   & lt; groupId> org.apache.maven.plugins   & lt; artifactId> maven-compiler-plugin   & lt; configuration>   & lt; source> 1.8 & lt;/source>   & lt; target> 1.8 & lt;/target>   & lt;/configuration>   & lt;/plugin>   & lt;/plugins>   & lt;/build>   & lt;/project>      

<强>二,spring的xml配置文件

        & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比;   & lt;豆类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”比;      & lt; bean id=" accountService”class=癱om.wuxi.services.impl.AccountServiceImpl”比;   & lt;属性名=" accountDao“ref=癮ccountDao祝辞& lt;/property>   & lt;/bean>      & lt; bean id=癮ccountDao”类=癱om.wuxi.daos.impl.AccountDaoImpl”比;   & lt;属性名=笆菰础眗ef=笆菰础弊4? lt;/property>   & lt;/bean>      & lt; bean id=笆菰础崩?皁rg.springframework.jdbc.datasource.DriverManagerDataSource”比;   & lt;属性名=" driverClassName " value=" https://www.yisu.com/zixun/com.mysql.cj.jdbc.Driver "祝辞& lt;/property>   & lt;属性名=" url "   值=" https://www.yisu.com/zixun/jdbc: mysql://192.168.2.105:3306/ssm ? characterEncoding=utf8&useSSL=false”祝辞& lt;/property>   & lt;属性名="用户名" value=" https://www.yisu.com/zixun/root "祝辞& lt;/property>   & lt;属性名="密码" value=" https://www.yisu.com/zixun/123456 "祝辞& lt;/property>   & lt;/bean>      & lt; !   春天中基于xml的声明式事务控制配置步骤   1,配置事务管理器   2、配置事务的通知   3、配置aop中的通用切入点表达式   4、建立事务通知和切入点表达式的对应关系   5、配置事务的属性   ——比;   & lt; !——事务管理器——比;   & lt; bean id=皌ransactionManager”类=皁rg.springframework.jdbc.datasource.DataSourceTransactionManager”比;   & lt;属性名=笆菰础眗ef=笆菰础弊4? lt;/property>   & lt;/bean>   & lt; !——事务的通知——比;   & lt; tx:建议id=皌xAdvice事务管理器”=皌ransactionManager”比;   & lt; !   事务的属性   隔离:用于指定事务的隔离级别。默认值是DEFAULE,表示使用数据库的默认隔离级别。   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

春如何基于xml实现声明式事务控制