cglib
参考:
https://www.runoob.com/w3cnote/cglibcode-generation-library-intro.html
spring 事务 EnableTransactionManagement 与 Transactional
先说spring自动配置 SpringBootApplication 注解,加载配置
bean 的加载,spring.factory 文件:https://blog.csdn.net/qq_32370913/article/details/105924209 (【springboot】为何不使用@EnableTransactionManagement就能使用事务?)
- org.springframework.boot.autoconfigure.EnableAutoConfiguration
- org.springframework.boot.autoconfigure.AutoConfigurationImportSelector
- org.springframework.boot.autoconfigure.AutoConfigurationImportSelector#selectImports
- org.springframework.boot.autoconfigure.AutoConfigurationImportSelector#getAutoConfigurationEntry
- org.springframework.boot.autoconfigure.AutoConfigurationImportSelector#getCandidateConfigurations
- org.springframework.core.io.support.SpringFactoriesLoader#loadFactoryNames
- org.springframework.core.io.support.SpringFactoriesLoader#loadSpringFactories (这里加载 spring.factory 文件)
此步是说明项目不加 EnableTransactionManagement 也可以使用事务(当然对应的方法必须可以拿到事务,不管是直接获取,还是从其他方法继承,还是别的(就是一个事务的传播))
加与不加 EnableTransactionManagement 到底有没有区别?
spring.factory 文件与事务相关的
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\
org.springframework.boot.autoconfigure.r2dbc.R2dbcTransactionManagerAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\
事务逻辑
https://www.jianshu.com/p/f84d50ba6d10 (声明式事务源码分析之EnableTransactionManagement,执行逻辑)