Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

2YSP/ship-sharding

Repository files navigation

ship-sharding

This is spring-boot-stater of sharding-jdbc,help you achieve database and table partitioning faster!

Project Structure

project name description
ship-sharding-spring-boot-starter core module
ship-sharding-example an example of how to use ship-sharding-spring-boot-starter
ship-sharding-nacos-example an example of how to use ship-sharding-spring-boot-starter,when using nacos as config center

Quick Start

  1. add this into pom.xml of your project
 <dependency>
 <groupId>cn.sp</groupId>
 <artifactId>ship-sharding-spring-boot-starter</artifactId>
 <version>1.0-SNAPSHOT</version>
 </dependency>
  1. Add sharding configurations to your local configuration file or nacos.

for example:

ship:
 sharding:
 jdbc:
 datasource:
 names: ds0
 ds0:
 driver-class-name: com.mysql.cj.jdbc.Driver
 type: com.alibaba.druid.pool.DruidDataSource
 url: jdbc:mysql://127.0.0.1:3306/my_springboot?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
 username: root
 password: 1234
 initial-size: 5
 minIdle: 5
 maxActive: 20
 maxWait: 60000
 timeBetweenEvictionRunsMillis: 60000
 minEvictableIdleTimeMillis: 300000
 validationQuery: SELECT 1 FROM DUAL
 testWhileIdle: true
 testOnBorrow: false
 testOnReturn: false
 poolPreparedStatements: true
 maxPoolPreparedStatementPerConnectionSize: 20
 useGlobalDataSourceStat: true
 connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=2000;druid.mysql.usePingMethod=false
 config:
 binding-tables: t_order
 tables:
 t_order:
 actual-data-nodes: ds0.t_order_${2022..2023}_${1..4}
 key-generator:
 type: DISTRIBUTED
 column: id
 table-strategy:
 standard:
 sharding-column: create_time
 precise-algorithm-class-name: cn.sp.sharding.algorithm.MyTableShardingAlgorithm
 range-algorithm-class-name: cn.sp.sharding.algorithm.MyTableShardingAlgorithm

About

spring-boot-starter of sharding-jdbc

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /