在使用sharding进行分裤读写分离时候报错
java.lang.IllegalStateException: Missing the data source name: 'null'
可以正常查询数据,添加和修改就会报错
在网上找了很多解决方案都不行
这是我的application.yml文件配置
server:
port: 8080
spring:
main:
allow-bean-definition-overriding: true
shardingsphere:
datasource:
names:
master,slave
# 主数据源
master:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.44.130:3306/reggie?characterEncoding=utf-8
username: root
password: root
# 从数据源
slave:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.44.131:3306/reggie?characterEncoding=utf-8
username: root
password: root
cofig:
masterslave:
# 读写分离配置
load-balance-algorithm-type: round_robin
# 最终的数据源名称
name: dataSource
# 主库数据源名称
master-data-source-name: master
# 从库数据源名称列表,多个逗号分隔
slave-data-source-names: slave
sharding:
tables:
table_a:
actual-data-nodes: ms-ds-$->{0..3}.table_a
props:
sql:
show: true #开启SQL显示,默认false
application:
name: reggie_take_out
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/reggie?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: root
redis:
host: localhost
port: 6379
cache:
redis:
time-to-live: 1800000 #缓存时间
mybatis-plus:
configuration:
#在映射实体或者属性时,将数据库中表名和字段名中的下划线去掉,按照驼峰命名法映射
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: ASSIGN_ID
#图片上传地址
reggie:
path: d:/img/
使用springboot2.4.5+mybatis-plus3.4.2+sharding-jdbc4.0.0
求帮个忙