totalo commented on issue #24292: URL: https://github.com/apache/shardingsphere/issues/24292#issuecomment-1441222332
> @totalo Thank you very much for your advice. It's a big help! > > As you said, after cloning and building the entire shardingsphere project, In the https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-example-generator/src/main/resources/config.yaml settings, you created an example source after setting it as follows: > > ``` > output: > - ./examples/shardingsphere-example-generator/target/generated-sources/ > products: > - jdbc > modes: > - standalone > transactions: > - local > features: > - sharding > frameworks: > - spring-boot-starter-mybatis > > props: > host: localhost > port: 3306 > username: root > password: 1234 > ``` > > When I run the ExampleMain.main() method of the 'sharding--spring-boot-starter-mybatis--standalone--local' project resulting in this, I get a message that there is no db. > > So, after generating the db as below, it was executed normally. Do you think this is a good example? > > ``` > create database `demo_ds_0` > create database `demo_ds_1` > create database `demo_ds_2` // This db is not actually used > ``` Yes, it should. The default is three libraries, because some of the example code will use three libraries. You can configure them with the feature module documentation. The main responsibility of the example module is to help users quickly verify some configurations. By generating general and normal running projects, we can let users personalize the corresponding configuration combined with the document, so that users can quickly verify whether the function meets the requirements and the correctness of the configuration. > > This is the example config.yaml. > > ``` > mode: > type: Standalone > repository: > type: JDBC > props: > path: demo > dataSources: > ds_0: > dataSourceClassName: com.zaxxer.hikari.HikariDataSource > driverClassName: com.mysql.jdbc.Driver > jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true > username: root > password: 1234 > maxPoolSize: 10 > ds_1: > dataSourceClassName: com.zaxxer.hikari.HikariDataSource > driverClassName: com.mysql.jdbc.Driver > jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true > username: root > password: 1234 > maxPoolSize: 10 > ds_2: > dataSourceClassName: com.zaxxer.hikari.HikariDataSource > driverClassName: com.mysql.jdbc.Driver > jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true > username: root > password: 1234 > maxPoolSize: 10 > rules: > - !SHARDING > tables: > t_order: > actualDataNodes: ds_$->{0..1}.t_order_$->{0..1} > tableStrategy: > standard: > shardingColumn: order_id > shardingAlgorithmName: t_order_inline > keyGenerateStrategy: > column: order_id > keyGeneratorName: snowflake_generator > t_order_item: > actualDataNodes: ds_$->{0..1}.t_order_item_$->{0..1} > tableStrategy: > standard: > shardingColumn: order_id > shardingAlgorithmName: t_order_item_inline > keyGenerateStrategy: > column: order_item_id > keyGeneratorName: snowflake_generator > bindingTables: > - t_order,t_order_item > broadcastTables: > - t_address > defaultDatabaseStrategy: > standard: > shardingColumn: user_id > shardingAlgorithmName: database_inline > shardingAlgorithms: > database_inline: > type: INLINE > props: > algorithm-expression: ds_${user_id % 2} > t_order_inline: > type: INLINE > props: > algorithm-expression: t_order_$->{order_id % 2} > t_order_item_inline: > type: INLINE > props: > algorithm-expression: t_order_item_$->{order_id % 2} > keyGenerators: > snowflake_generator: > type: SNOWFLAKE > props: > sql-show: true > ``` > > If so, I think it would be good to add a code to make a db or specify in the guide that there should be a db in advance. Yes, we are negligent. I will improve the document later. > Also, https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-example-generator/src/main/resources/config.yaml Is there a guide to setting up this file? I want to know what each means. > > Thank you for your kind explanation! hi @taetaetae, Glad to help, this example generation module is a brand new pattern that was recently completed. There's still a lot to be desired. We'll cover this in detail in a future article. Currently you can view the configuration of The Times[1]. Looking forward to your suggestions, let us make the example module better. [1] https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-example-generator/README.md -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
