AutoConfigurationImportSelector是springboot的一个核心配置类,springboot项目启动时,此类会自动加载许多框架,如下:

springboot如何与mybatis集成(源码底层实现)

如上图,一共98个框架,

那么此类时如何去找到这些框架并 获取对象呢?

答:在这些框架中,每个框架都有一个spring.factories文件,在这些文件中都有各个文件的全限定类名地址,

springboot如何与mybatis集成(源码底层实现)

springboot如何与mybatis集成(源码底层实现)

springboot启动后,AutoConfigurationImportSelector类中调用SpringFactoriesLoader类中的loadFactoryNames方法获取list集合

springboot如何与mybatis集成(源码底层实现)

springboot如何与mybatis集成(源码底层实现)

自动找到这些框架中的spring.factories文件,得到类名地址,调用该类

springboot如何与mybatis集成(源码底层实现)

springboot如何与mybatis集成(源码底层实现)

该类中通过@Bean将获取的工厂对象放入spring容器中,由spring管理,

由此,springboot与mybatis集成完毕。

相关文章:

  • 2021-09-08
  • 2021-08-10
  • 2021-12-24
  • 2021-09-11
  • 2022-12-23
  • 2021-10-02
  • 2021-05-04
  • 2021-05-10
猜你喜欢
  • 2021-11-22
  • 1970-01-01
  • 2021-06-19
  • 2022-12-23
  • 2021-09-26
  • 2021-12-24
  • 2022-12-23
相关资源
相似解决方案