关于智能协同云图库的分库分表配置失败问题

本人完全按照鱼总教程的格式,但是还是出现一大片报错,就是createBean失败等等

Can not find data source type 经过排查应该是对应sharingSphere没有识别或者没有正确链接到mysql 如果理解有误或者会出现什么隐藏的问题,请大佬们多多指教。

我按以下方式解决:

然后yml中修改数据库配置(不带参数 ShardingSphere 5.2.0 就会可能抛 SQLWrapperException):

yaml
复制代码
# 空间图片分表 shardingsphere: datasource: names: yun_picture yun_picture: type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/yun_picture?useSSL=false&characterEncoding=utf8&serverTimezone=UTC&allowPublicKeyRetrieval=true username: root password: 1234 rules: sharding: tables: picture: actual-data-nodes: yun_picture.picture # 动态分表 table-strategy: standard: sharding-column: spaceId sharding-algorithm-name: picture_sharding_algorithm # 使用自定义分片算法 sharding-algorithms: picture_sharding_algorithm: type: CLASS_BASED props: strategy: standard algorithmClassName: com.hhz.yunPictureBackend.manager.sharding.PictureShardingAlgorithm props: sql-show: true

在pom.xml添加(可以尝试不加看看):

xml
复制代码
第二步:确保 pom.xml 有数据库连接池依赖(必须有) xml <!-- 连接池 HikariCP(Spring Boot 默认自带,但有时候被排除了,加上保险) --> <dependency> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> </dependency> <!-- MySQL --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency>

这样以后就能正常出现表了

1775806272313.png

0个评论
点击登录,快来和大家讨论吧~
表情
图片
暂无评论
下载 APP