1 Star 4 Fork 1

xcc/sharding-jdbc

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
application_1d2t.properties 1.78 KB
Copy Edit Raw Blame History
xcc authored 2021-01-24 23:39 +08:00 . 解决中文乱码
#单库多表的配置 水平分表
server.port=56081
spring.application.name=sharding‐jdbc-demo
server.servlet.context‐path=/sharding‐jdbc-demo
#编码
spring.http.encoding.enabled=true
spring.http.encoding.charset=utf-8
spring.http.encoding.force=true
spring.main.allow-bean-definition-overriding=true
#将数据库的_字段自动映射为驼峰
mybatis.configuration.map-underscore-to-camel-case=true
# 打开sql输出日志
spring.shardingsphere.props.sql.show=true
swagger.enable=true
#log日志配置
logging.level.root=info
logging.level.org.springframework.web=info
logging.level.com.xcc.dbsharding=debug
logging.level.druid.sql=debug
#sharding-jdbc分片规则配置
#数据源
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.url=jdbc:mysql://hadoop102:3306/order_db?useUnicode=true&characterEncoding=utf8
spring.shardingsphere.datasource.m1.username=root
spring.shardingsphere.datasource.m1.password=123456
# 指定t_order表的数据分布情况,配置数据节点 m1.t_order_1,m1.t_order_2
spring.shardingsphere.sharding.tables.t_order.actual-data-nodes=m1.t_order_$->{1..2}
# 指定t_order表的主键生成策略为SNOWFLAKE
spring.shardingsphere.sharding.tables.t_order.key-generator.column=order_id
spring.shardingsphere.sharding.tables.t_order.key-generator.type=SNOWFLAKE
# 指定t_order表的分片策略,分片策略包括分片键(order_id)和分片算法(t_order_$->{order_id % 2 + 1})
spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.sharding-column=order_id
spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.algorithm-expression=t_order_$->{order_id % 2 + 1}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/xiaocheng0902/sharding-jdbc.git
git@gitee.com:xiaocheng0902/sharding-jdbc.git
xiaocheng0902
sharding-jdbc
sharding-jdbc
master

Search