一、Spring Boot通过扫描带@Configuration注解的MybatisAutoConfiguration。
MybatisAutoConfiguration将MapperScannerConfigurer注入IOC容器,并调用MapperScannerConfigurer.postProcessBeanDefinitionRegistry方法。
二、MapperScannerConfigurer.postProcessBeanDefinitionRegistry调用ClassPathMapperScanner父类ClassPathBeanDefinitionScanner的scan方法。
scan方法再调用doScan方法,扫描指定目录下的Mapper接口。
每一个Mapper接口,以类名的全称作为名称,以MybatisMapperProxy作为值,注入IOC容器。
三、Spring 调用Mapper某个方法时,通过MybatisMapperProxy代理进行调用。
四、查询数据库记录时,通过对象名称和属性值,利用SQL解析类,生成对应的SQL,查询数据库。