两个数据库
1,依赖
com.baomidou
dynamic-datasource-spring-boot-starter
1.0.0
2,yml
spring:
datasource:
dynamic:
#primary: master #设置默认的数据源或者数据源组,默认值即为master
#strict: false #设置严格模式,默认false不启动. 启动后在未匹配到指定数据源时候会抛出异常,不启动则使用默认数据源.
#datasource:
master:
url: jdbc:mysql://ip+端口/woke_cloud_social?characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=CTT&tinyInt1isBit=false
username:
password:
#driver-class-name: com.mysql.jdbc.Driver
slave:
slave_1:
url: jdbc:mysql://ip+端口/woke_cloud_property?characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=CTT&tinyInt1isBit=false
username:
password:
#driver-class-name: com.mysql.jdbc.Driver
3,在mapper加从节点的注解
标签:jdbc,false,SpringBoot,数据源,master,datasource,mysql,之多
来源: https://www.cnblogs.com/yangxiaoli/p/13985696.html