[Mybatis source code analysis] mapper instantiation and execution process source code analysis

Basic environment: JDK17, SpringBoot3.0, mysql5.7

Reserve knowledge: "[Spring6 Source Code・AOP] AOP Source Code Analysis" , "JDBC Detailed Explanation"

Introduction

Analysis of Mybatis source code based on SpringBoot:

1. How to instantiate beans for mapper

When loading BeanDefinition, SqlSessionFactory, SqlSessionTemplate, MapperScannerConfigurer will be loaded into the registry for subsequent instantiation.

And during this period, the mapper interface has been instantiated, and it can be taken out of the cache later.

When initializing,

The first step is to use SqlSessionFactoryBean to generate SqlSessionFactory. During the generation process, MapperAnnotationBuilder is used to parse the annotation on the mapper interface, put it in Configuration, and then put it in SqlSessionFactory, and put the created SqlSessionFactory instance into the bean cache pool.

The second step is to use SqlS

Guess you like

Origin blog.csdn.net/CSDN_SAVIOR/article/details/129039435