sharding在application中的配置

本文详细介绍了在application中配置sharding的四个主要步骤:公共配置、水平分表、水平分库+分表以及垂直分库分表。水平分表关注单数据源的分表策略,而水平+分库则涉及多数据源。垂直分库是根据业务逻辑将表分布到不同数据库,保持单数据表操作。最后,讲解了绑定表的设置,强调其从tables[0]开始的数组方式。
摘要由CSDN通过智能技术生成

sharding在application中的配置

1.公共配置

server.port=8080

spring.application.name=sharding
# 驼峰转换
mybatis.configuration.map-underscore-to-camel-case=true


# 打开sharding日志
spring.shardingsphere.props.sql.show=true

# 允许bean覆盖,防止bean和springboot注入冲突
spring.main.allow-bean-definition-overriding=true

#  各日志级别设置
logging.level.root=info
logging.level.org.springframework.web=info
logging.level.com.example.sharding=debug
logging.level.druid.sql=debug

2.水平分表设置

单数据源数据水平分表设置


# 配置多数据源
spring.shardingsphere.datasource.names=m1


spring.shardingsphere.datasource.m1.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.m1.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.m1.username=root
spring.shardingsphere.datasource.m1.password=12345
spring.shardingsphere.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值