1 简介

MyBatis在SpringBoot中作为操作数据库MySQL的重要中间件工具,被广泛应用。
SpringBoot启动时自动装配需要的组件,使用容器管理Bean,
MyBatis作为数据库操作组件,同样需要纳入SpringBoot自动装配范围。
下面介绍MyBtis如何在SpringBoot中完成自动装配。

2 配置文件

src/main/resources/application.yml

mybatis:
  config-location: classpath:/config/mybatis-config.xml
  mapper-locations: classpath:mapper/*.xml

3 注册BeanDefinition

org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration.AutoConfi

更多推荐

MyBatis是如何自动装配的