sharding-jdbc的mrg没有自动识别有写入权限的主库

使用环境:

springboot+sharding-jdbc 5.1.1+mybatisplus+mysql+mrg

场景、问题:

在进行新增数据时,sharding-jdbc没有自动识别有写入权限的主库,而是使用只有读取权限的从库进行写入。

springboot配置文件如下

# 内存模式
spring.shardingsphere.mode.type=Memory

# 配置真实数据源
spring.shardingsphere.datasource.names=master,slave1,slave2

# 配置第 1 个数据源
spring.shardingsphere.datasource.master.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.master.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.master.jdbc-url=jdbc:mysql://10.0.0.93:3306/dbtest
spring.shardingsphere.datasource.master.username=root
spring.shardingsphere.datasource.master.password=123456

# 配置第 2 个数据源
spring.shardingsphere.datasource.slave1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.slave1.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.slave1.jdbc-url=jdbc:mysql://10.0.0.92:3306/dbtest
spring.shardingsphere.datasource.slave1.username=root
spring.shardingsphere.datasource.slave1.password=123456

# 配置第 3 个数据源
spring.shardingsphere.datasource.slave2.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.slave2.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.slave2.jdbc-url=jdbc:mysql://10.0.0.94:3306/dbtest
spring.shardingsphere.datasource.slave2.username=root
spring.shardingsphere.datasource.slave2.password=123456

spring.shardingsphere.rules.database-discovery.data-sources.myds.data-source-names=master,slave1,slave2
spring.shardingsphere.rules.database-discovery.data-sources.myds.discovery-heartbeat-name=heartbeat
spring.shardingsphere.rules.database-discovery.data-sources.myds.discovery-type-name=discovery-type
spring.shardingsphere.rules.database-discovery.discovery-heartbeats.heartbeat.props.keep-alive-cron='0/5 * * * * ?'
spring.shardingsphere.rules.database-discovery.discovery-types.discovery-type.type=MGR
spring.shardingsphere.rules.database-discovery.discovery-types.discovery-type.props.group-name=aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa

现状:

MRG集群配置如下

代码如下
image

报错信息如下

京ICP备2021015875号