1.x的示例,请参阅 https://github.com/apache/shardingsphere/tree/${tag}/shardingsphere-jdbc-example
2.x或3.x或4.x的示例,请参见 https://github.com/apache/shardingsphere-example/tree/${tag}
需要注意
请不要使用dev
分支来运行您的示例,dev
分支的示例尚未发布。
手动模式初始脚本位于 https://github.com/apache/shardingsphere-example/blob/dev/src/resources/manual_schema.sql
,请在首次运行示例之前执行它。
请确保MySQL上的主从数据同步正确运行。否则,此示例查询从库数据将是空。
dev
分支,请在开始该example之前请确保已安装了来自shardingsphere 和 shardingsphere-spi-impl的某些依赖项,因为某些示例依赖于此。如果您是shardingsphere的新手,您可以准备如下依赖:
1.下载并安装shardingsphere:
## 下载shardingsphere代码 git clone https://github.com/apache/shardingsphere.git ## 检出一个指定版本,比如是 4.0.0-RC1 cd shardingsphere && git checkout 4.0.0-RC1 ## 安装依赖 mvn clean install -Prelease
2.下载并安装shardingsphere-spi-impl:
## 下载shardingsphere-SPI-implement的代码 git clone https://github.com/OpenSharding/shardingsphere-spi-impl.git ## 检出一个指定版本,比如是 4.0.0-RC1 cd shardingsphere-spi-impl && git checkout 4.0.0-RC1 ## 安装依赖 mvn clean install
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
例子 | 描述 |
---|---|
分片 | 演示了如何通过 ShardingSphere-JDBC 进行分库、分表、主从等 |
springboot jpa | 演示了如何通过 SpringBoot JPA 对接 ShardingSphere |
springboot mybatis | 演示了如何通过 SpringBoot Mybatis 对接 ShardingSphere |
orchestration | 演示了如何在 ShardingSphere 中使用 orchestration |
事务 | 演示了如何在 ShardingSphere 中使用事务 |
hint | 演示了如何在 ShardingSphere 中使用 hint |
加密 | 演示了如何在 ShardingSphere 中使用加密 |
APM监控(Pending) | 演示了如何在 ShardingSphere 中使用 APM 监控 |
proxy(Pending) | 演示了如何使用 sharding proxy |
docker | 演示了如何通过 docker 创建 ShardingSphere 所依赖的环境 |