zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Spring Boot MyBatis配置多种数据库

2023-09-27 14:24:45 时间

mybatis-config.xml是支持配置多种数据库的,本文将介绍在Spring Boot中使用配置类来配置。

1. 配置application.yml

# mybatis配置
mybatis:
  check-config-location: false
  type-aliases-package: ${base.package}.model
  configuration:
    map-underscore-to-camel-case: true
    # 二级缓存的总开关
    cache-enabled: false
  mapper-locations: classpath:mapping/*.xml

2. 新增数据源配置类