shardingsphere v4.0.0以及v4.1.1版本

使用shardingsphere 进行分表操作

shardingsphere v4.0.0 会存在分页BUG 报错int类型不能转为Long类型问题

需要升级到v4.1.1

v4.0.0的配置为

复制代码
#数据配置
spring.shardingsphere.datasource.names: m1
spring.shardingsphere.datasource.m1.type: com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.m1.driver‐class‐name:  com.mysql.jdbc.Driver
spring.shardingsphere.datasource.m1.jdbc-url: jdbc:mysql://IP:3306/库名?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false
spring.shardingsphere.datasource.m1.username: 用户名
spring.shardingsphere.datasource.m1.password: 密码

#分表依据字段设置
spring.shardingsphere.sharding.tables.表名.table-strategy.standard.sharding-column:  create_time
spring.shardingsphere.sharding.tables.表名.table-strategy.standard.precise-algorithm-class-name: 分表策略类名

升级后 配置文件中必须含有

复制代码
spring.shardingsphere.sharding.tables.cn_call_log_execute_time.actual-data-nodes

否则启动会报错

复制代码
#日志表分表配置
spring.shardingsphere.datasource.names: m1
spring.shardingsphere.datasource.m1.type: com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.m1.driver‐class‐name:  com.mysql.jdbc.Driver
spring.shardingsphere.datasource.m1.jdbc-url: jdbc:mysql://IP:3306/库名?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false
spring.shardingsphere.datasource.m1.username: 用户名
spring.shardingsphere.datasource.m1.password: 密码

#分表依据字段设置
spring.shardingsphere.sharding.tables.表名.actual-data-nodes: m1.表名_$->{1..7}
spring.shardingsphere.sharding.tables.表名.table-strategy.standard.sharding-column:  create_time
spring.shardingsphere.sharding.tables.cn_call_log.table-strategy.standard.precise-algorithm-class-name: 分表策略类名
相关推荐
顶点多余几秒前
数据库——对表的操作
数据库
程序员榴莲3 分钟前
MySQL (一):MySQL的安装与启动
数据库·mysql
⑩-8 分钟前
@Vaild
java·javaee
fie88899 分钟前
Spinal码MATLAB实现(采用One-at-a-Time哈希函数)
开发语言·matlab·哈希算法
咖啡の猫11 分钟前
Redis 通用命令
数据库·redis·bootstrap
Han.miracle12 分钟前
Spring Boot 后端分层开发实战:从 MVC 到三层架构详解
java
invicinble19 分钟前
it系统全链路思考
java
IT界的老黄牛20 分钟前
【IT老齐230 笔记 + 思考】金融业容灾方案“两地三中心“是什么意思?
数据库·笔记·架构
aiAIman20 分钟前
OpenClaw 用户必修课:(三)Claude Code 单一聊天原则、Hooks 与 LSP
数据库·人工智能·开源·aigc
steel808820 分钟前
SSM与Springboot是什么关系? -----区别与联系
java·spring boot·后端