0
点赞
收藏
分享

微信扫一扫

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


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

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

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


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


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

@EnableTransactionManagement注解:

SpringBoot复习:(53)TransactionInterceptor是在哪里配置的?_字符串_03


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

SpringBoot复习:(53)TransactionInterceptor是在哪里配置的?_字符串_04


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

SpringBoot复习:(53)TransactionInterceptor是在哪里配置的?_字符串_05


举报

相关推荐

jvm在哪里?

0 条评论