项目使用Springboot加载mybatis-plus。
1、先看mybatis
![](https://img-blog.csdnimg.cn/img_convert/0b3523fe02920caad3193eb0d57ae8a4.png)
refresh会调用beanFactory的事件处理器执行处理。而方法内部
![](https://img-blog.csdnimg.cn/img_convert/31db600f0fc04d5f16db2e4d1a0b6af6.png)
会调用bean定义注册执行处理器进行事件处理
最终
![](https://img-blog.csdnimg.cn/img_convert/176a4600761c784513c2094aba9dd678.png)
到mybatis-sprng包内的注册bean方法内执行。
这个方法会将注解mapperScan以及他注入的值加载进来
![](https://img-blog.csdnimg.cn/img_convert/8a4d9fca6c4d34351bac316a9124cb5a.png)
这个方法会用bean定义构造器生成一个mapperscannerconfigurer的定beanDefinitionRefistry对象,并将mapperscan内设定的值设置进去。
根据上面basePackage配置的mapper class路径加载
![](https://img-blog.csdnimg.cn/img_convert/d56ff71fd8ece0df1c0664ba8d35217d.png)
![](https://img-blog.csdnimg.cn/img_convert/a1b6b444a39a172e69923dc2aa44ee6d.png)