首页 > 其他分享 >SpringBoot复习:(53)TransactionInterceptor是在哪里配置的?

SpringBoot复习:(53)TransactionInterceptor是在哪里配置的?

时间:2023-08-21 17:34:47浏览次数:38  
标签:SpringBoot ProxyTransactionManagementConfiguration TransactionInterceptor bean T


我们知道SpringBoot的事务(@Transactional)最终是通过TransactionInterceptor的invoke方法调用invokeWithinTransaction方法来开启事务控制的。

TransactionInterceptor bean在哪里配置的呢?在ProxyTransactionManagementConfiguration:

SpringBoot复习:(53)TransactionInterceptor是在哪里配置的?_java


SpringBoot复习:(53)TransactionInterceptor是在哪里配置的?_spring boot_02


可以看到这里创建了一个TransactionInterceptor类型的bean并且注入到了BeanFactoryTransactionAttributeSourceAdvisor这个bean.##############################################################################

@EnableTransactionManagement注解:

SpringBoot复习:(53)TransactionInterceptor是在哪里配置的?_java_03


@EnableTransactionManagement注解使用@Import注解导入了TransactionManagementConfigurationSelector类,这个类代码如下:

SpringBoot复习:(53)TransactionInterceptor是在哪里配置的?_java_04


因为TransactionManagementConfigurationSelector实现了ImportSelector接口,所以它的selectImports方法返回的字符串数组中的字符串(类的全限定名)就会被用来创建bean,因此容器中会存在一个类型为ProxyTransactionManagementConfiguration的bean.而类型为ProxyTransactionManagementConfiguration的配置类bean中定义了一个类型为TransactionInterceptor的bean

SpringBoot复习:(53)TransactionInterceptor是在哪里配置的?_后端_05


标签:SpringBoot,ProxyTransactionManagementConfiguration,TransactionInterceptor,bean,T
From: https://blog.51cto.com/amadeusliu/7177771

相关文章

  • SpringBoot复习(54)用于事务处理的InfrastructureAdvisorAutoProxyCreator BeanPostProc
    从类的继承关系看InfrastructureAdvisorAutoProxyCreator是一个BeanPostProcessor.@EnableTransactionManagement注解导入了TransactionManagementConfigurationSelector类,它的代码如下:这个ImportSelector的selectImports方法返回了一个AutoProxyRegistrar,AutoProxyRegistrar代码......
  • SpringBoot复习:(38)WebServerFactoryCustomizer
    可以通过这种方式对内嵌的Servlet容器进行配置packagecn.edu.tju.config;importorg.springframework.boot.web.server.ConfigurableWebServerFactory;importorg.springframework.boot.web.server.WebServerFactory;importorg.springframework.boot.web.server.WebServerFac......
  • SpringBoot复习:(41)配置文件中配置的server开头的属性是怎么配置到Servlet容器中起作用
    ServletWebServerFactoryAutoConfiguration类:可以看到其中使用了@EnableConfigurationProperties导入了ServerProperties而ServerProperties通过使用@ConfigurationProperties注解导入了配置文件中已server开头的那些配置项。可以看到ServletWebServerFactory定义了一个类型为Se......
  • SpringBoot复习:(33)WebMvcAutoconfiguration内部静态类WebMvcAutoConfigurationAdapter
    WebMvcAutoconfiguration内部静态类WebMvcAutoConfigurationAdapter实现了WebMvcConfigurer接口,重写了一些方法,也就是默认对SpringMvc进行了一些配置:该静态类上有个**@Import**注解:@Import(EnableWebMvcConfiguration.class)它的父类DelegatingWebMvcConfiguration,通过注入......
  • SpringBoot如何进行统一版本的管理
    在springboot中,可以通过以下两种方式实现统一版本的管理:1、通过标签<parent>如:<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.4.1.......
  • 代码随想录算法训练营第二十一天| 530.二叉搜索树的最小绝对差 501.二叉搜索树中的
     530.二叉搜索树的最小绝对差   卡哥建议:需要领悟一下二叉树遍历上双指针操作,优先掌握递归   题目链接/文章讲解:https://programmercarl.com/0530.%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%E7%9A%84%E6%9C%80%E5%B0%8F%E7%BB%9D%E5%AF%B9%E5%B7%AE.html ......
  • springboot利用hutool快速生成验证码
    生成验证码publicclassVerificationCodeUtil{publicstaticVerificationCodegetVerification(){LineCaptchacaptcha=CaptchaUtil.createLineCaptcha(70,35,4,30);Stringkey=IdUtil.get32Uuid();VerificationCodeverificationCode......
  • 在springboot项目中部署vue打包的dist以及刷新遇到404的解决方法
    一、在springboot项目中部署dist新建一个springboot项目,并将dist复制到resources目录下面,同时在application.yml添加配置即可,操作结果如下图所示: 添加的配置代码如下:spring:web:resources:static-locations:"classpath:/dist"二、部署好之后刷新遇到404......
  • Springboot-starter
    1.Spring手动注入和自动注入通常情况下,系统中类和类之间是有依赖关系的,如果一个类对外提供的功能需要通过调用其他类的方法来实现的时候,说明这两个类之间存在依赖关系。example:publicclassUserService{publicvoidinsert(UserModelmodel){//插入用户信息......
  • html多文件上传(springboot)
    一、文件的上传1、前端html上传文件(1)html代码:<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Title</title><linkrel="stylesheet"href="https://cdn.staticfile.org......