- spring:
- shardingsphere:
- names:
- master,slave
- #主数据源
- master:
- type: com.alibaba.druid.pool.DruidDataSource
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://192.168.138.100:3306/rw?characterEncoding=utf-8
- username: root
- password: 123456
- #从数据源
- slave:
- type: com.alibaba.druid.pool.DruidDataSource
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://192.168.138.101:3306/rw?characterEncoding=utf-8
- username: root
- password: 123456
- masterslave:
- #读写分离配置
- load-balance-algorithm-type: round_robin #轮询
- #最终的数据源名称
- name: dataSource
- #主库数据源名称
- master-data-source-name: master
- #从库数据源名称列表,多个逗号分隔
- slave-data-source-names: slave
- props:
- sql:
- show: true #开启SQL显示,默认false
- #在配置文件中配置允许bean定义覆盖配置项
- main:
- allow-bean-definition-overriding: true
- spring:
- shardingsphere:
- names:
- master,slave
- #主数据源
- master:
- type: com.alibaba.druid.pool.DruidDataSource
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://192.168.138.100:3306/rw?characterEncoding=utf-8
- username: root
- password: 123456
- #从数据源
- slave:
- type: com.alibaba.druid.pool.DruidDataSource
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://192.168.138.101:3306/rw?characterEncoding=utf-8
- username: root
- password: 123456
- masterslave:
- #读写分离配置
- load-balance-algorithm-type: round_robin #轮询
- #最终的数据源名称
- name: dataSource
- #主库数据源名称
- master-data-source-name: master
- #从库数据源名称列表,多个逗号分隔
- slave-data-source-names: slave
- props:
- sql:
- show: true #开启SQL显示,默认false
- #在配置文件中配置允许bean定义覆盖配置项
- main:
- allow-bean-definition-overriding: true