tree: 74ec26cd1ab99e78ffc01a942a32c0781019d3a6 [path history] [tgz]
  1. docker/
  2. example-core/
  3. shardingsphere-jdbc-example/
  4. shardingsphere-proxy-example/
  5. src/
  6. pom.xml
  7. README.md
  8. README_ZH.md
examples/README.md

ShardingSphere-example

Example for 1.x please see tags in https://github.com/apache/shardingsphere/tree/${tag}/shardingsphere-jdbc-example

Example for 2.x or 3.x or 4.x please see tags in https://github.com/apache/shardingsphere-example/tree/${tag}

Need attention

  • Please do not use dev branch to run your example, example of dev branch is not released yet.

  • The manual schema initial script is in https://github.com/apache/shardingsphere-example/blob/dev/src/resources/manual_schema.sql, please execute it before you first run the example.

  • Please make sure master-slave data sync on MySQL is running correctly. Otherwise this example will query empty data from slave.

Before start the example if you want use dev branch

Please make sure some dependencies from shardingsphere and shardingsphere-spi-impl have been installed since some examples depend on that. if you are a newbie for shardingsphere, you could prepare the dependencies as following:

1.download and install shardingsphere:

## download the code of shardingsphere
git clone https://github.com/apache/shardingsphere.git

## checkout a specific version, example is 4.0.0-RC1
cd shardingsphere && git checkout 4.0.0-RC1

## install the dependencies
mvn clean install -Prelease

2.download and install shardingsphere-spi-impl:

## download the code of shardingsphere-spi-impl
git clone https://github.com/OpenSharding/shardingsphere-spi-impl.git

## checkout a specific version, example is 4.0.0-RC1
cd shardingsphere-spi-impl && git checkout 4.0.0-RC1

## install the dependencies
mvn clean install

shardingsphere-example module design

project structure

shardingsphere-example
  ├── example-core
  │   ├── config-utility
  │   ├── example-api
  │   ├── example-raw-jdbc
  │   ├── example-spring-jpa
  │   └── example-spring-mybatis
  ├── shardingsphere-jdbc-example
  │   ├── sharding-example
  │   │   ├── sharding-raw-jdbc-example
  │   │   ├── sharding-spring-boot-jpa-example
  │   │   ├── sharding-spring-boot-mybatis-example
  │   │   ├── sharding-spring-namespace-jpa-example
  │   │   └── sharding-spring-namespace-mybatis-example
  │   ├── orchestration-example
  │   │   ├── orchestration-raw-jdbc-example
  │   │   ├── orchestration-spring-boot-example
  │   │   └── orchestration-spring-namespace-example
  │   ├── transaction-example
  │   │   ├── transaction-2pc-xa-example
  │   │   └──transaction-base-seata-example
  │   ├── other-feature-example
  │   │   ├── hint-example
  │   │   └── encrypt-example
  ├── shardingsphere-proxy-example
  │   ├── shardingsphere-proxy-boot-mybatis-example
  │   └── shardingsphere-proxy-hint-example
  └── src/resources
        └── manual_schema.sql

Available Examples

ExampleDescription
shardingshow how to use sharding-table\sharding-database\master-slave with ShardingSphere-JDBC
springboot jpashow how to use SpringBoot JPA with ShardingSphere
springboot mybatisshow how to use SpringBoot Mybatis with ShardingSphere
orchestrationshow how to use ShardingSphere orchestration
transactionshow how to use ShardingSphere transaction
hintshow how to use ShardingSphere hint
encryptionshow how to use ShardingSphere encryption
APM(Pending)show how to use APM in ShardingSphere
proxy(Pending)show how to use sharding proxy
dockershow how to use docker to setup the environment for ShardingSphere