spring boot整合sharding-sphere实现分库分表

本文介绍了如何使用Sharding-Sphere的Sharding-JDBC组件在Spring Boot应用中实现分库分表。通过配置POM文件、设置Spring Boot和Mybatis基础、定义分库策略以及配置application文件,实现了高并发系统的数据库架构优化。测试结果显示数据成功分散到不同数据库的表中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先,为什么使用sharding-JDBC,看这个

https://blog.youkuaiyun.com/qq_42046105/article/details/87944673

支撑日活百万用户的高并发系统,应该如何设计其数据库架构?【石杉的架构笔记】

640?wx_fmt=png

640?wx_fmt=png

 

理一下关系,sharding-jdbc和sharding-sphere什么区别?看这个

https://blog.youkuaiyun.com/hongthink/article/details/83863439

sharding-sphere生态sharding-jdbc、Sharding-Proxy和Sharding-Sidecar简介

sharding-jdbc 3.0版本:更名为sharding-sphere

 

下面开始核心实战:

第一,pom文件:

<!--JSON-->
<dependency>
   <groupId>com.alibaba</groupId>
   <artifactId>fastjson</artifactId>
   <version>1.1.41</version>
</dependency>
<!--JSON-->
<dependency>
   <groupId>com.alibaba</groupId>
   <artifactId>druid-spring-boot-starter</artifactId>
   <version>1.1.16</version>
</dependency>

<dependency>
   <groupId>org.apache.shardingsphere</groupId>
   <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
   <version>4.0.0-RC1</version>
</dependency>

第二,搭建好spring boot整合mybatis基础;dao/mapper文件-service-controller模型

server.port= 84
my
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值