如何编译shardingsphere-example

shardingsphere-example模块是基于ShardingSphere 5.0.0-RC1-SNAPSHOT(master)版本的,5.0.0-RC1-SNAPSHOT版本尚未发布,因此可能导致您的依赖导入失败。您有如下两只最有效方式可以选择,或许可以有效地帮助您编译并运行examples模块。

方式一

如果您想选择稳定版本的ShardingSphere,您可以将ShardingSphere的版本降低为5.0.0-alpha,您只需将examples模块下的pom.xml中的shardingsphere.version由5.0.0-RC1-SNAPSHOT降低为5.0.0-alpha即可。
事实上,5.0.0-alpha版本与5.0.0-RC1-SNAPSHOT存在一些差异,因此可能会导致您的运行,甚至编译失败。为了避免造成困扰,在其他的Markdown文件中将会为您提供有效的修改方案。

方式二

或许您想要使用5.0.0-RC1-SNAPSHOT版本运行examples,您需要做出如下几项操作。

获取源码

在您的本地目录下执行git clone https://github.com/apache/shardingsphere.git或者通过压缩包的方式下载到您的本地。

编译源码

源码准备好以后进入到源码所在的根目录执行以下命令:
mvn clean install -P release
编译完成后即可使用5.0.0-RC1-SNAPSHOT版本来运行您的examples了。

关于ShardingSphere-example

为了更加方便您的使用,接下来将会对每一个模块进行分析,有的模块甚至会为您可能遇到的问题提出解决的方法。
exmaples部分结构如下:

  1. shardingsphere-example
  2. ├── example-core
  3. ├── config-utility
  4. ├── example-api
  5. ├── example-raw-jdbc
  6. ├── example-spring-jpa
  7. └── example-spring-mybatis
  8. ├── shardingsphere-jdbc-example
  9. ├── sharding-example
  10. ├── sharding-raw-jdbc-example
  11. ├── sharding-spring-boot-jpa-example
  12. ├── sharding-spring-boot-mybatis-example
  13. ├── sharding-spring-namespace-jpa-example
  14. └── sharding-spring-namespace-mybatis-example
  15. ├── governance-example
  16. ├── governance-raw-jdbc-example
  17. ├── governance-spring-boot-example
  18. └── governance-spring-namespace-example
  19. ├── transaction-example
  20. ├── transaction-2pc-xa-example
  21. └── transaction-base-seata-example
  22. ├── other-feature-example
  23. ├── hint-example
  24. └── encrypt-example
  25. ├── shardingsphere-proxy-example
  26. ├── shardingsphere-proxy-boot-mybatis-example
  27. └── shardingsphere-proxy-hint-example
  28. └── src/resources
  29. └── manual_schema.sql