You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/11/19 07:02:13 UTC
[shardingsphere] branch master updated: fix spring namespace doc
This is an automated email from the ASF dual-hosted git repository.
zhangyonglun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 88f6d93 fix spring namespace doc
new 6a2ce6d Merge pull request #8219 from yu199195/fix-doc1
88f6d93 is described below
commit 88f6d93b09ec64bbb59f631fe00c1e8b3448c5ff
Author: yu199195 <54...@qq.com>
AuthorDate: Thu Nov 19 14:55:44 2020 +0800
fix spring namespace doc
---
.../usage/sharding/spring-namespace.cn.md | 46 ++++++++++++------
.../usage/sharding/spring-namespace.en.md | 54 ++++++++++++++--------
2 files changed, 66 insertions(+), 34 deletions(-)
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/spring-namespace.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/spring-namespace.cn.md
index 4eddf14..0ed852f 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/spring-namespace.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/spring-namespace.cn.md
@@ -43,32 +43,48 @@ weight = 4
<!-- 配置分库策略 -->
<sharding:sharding-algorithm id="dbShardingAlgorithm" type="INLINE">
- <properties>
+ <props>
<prop key="algorithm-expression">ds$->{user_id % 2}</prop>
- </properties>
+ </props>
</sharding:sharding-algorithm>
<sharding:standard-strategy id="dbStrategy" sharding-column="user_id" algorithm-ref="dbShardingAlgorithm" />
<!-- 配置分表策略 -->
<sharding:sharding-algorithm id="tableShardingAlgorithm" type="INLINE">
- <properties>
+ <props>
<prop key="algorithm-expression">t_order$->{order_id % 2}</prop>
- </properties>
+ </props>
</sharding:sharding-algorithm>
<sharding:standard-strategy id="tableStrategy" sharding-column="user_id" algorithm-ref="tableShardingAlgorithm" />
+
+ <!-- 配置分布式id生成策略 -->
+ <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
+ <props>
+ <prop key="worker-id">123</prop>
+ </props>
+ </sharding:key-generate-algorithm>
+ <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
+
+ <!-- 配置sharding策略 -->
+ <sharding:rule id="shardingRule">
+ <sharding:table-rules>
+ <sharding:table-rule logic-table="t_order" actual-data-nodes="ds${0..1}.t_order_${0..1}" database-strategy-ref="dbStrategy" table-strategy-ref="tableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
+ </sharding:table-rules>
+ <sharding:binding-table-rules>
+ <sharding:binding-table-rule logic-tables="t_order,t_order_item"/>
+ </sharding:binding-table-rules>
+ <sharding:broadcast-table-rules>
+ <sharding:broadcast-table-rule table="t_address"/>
+ </sharding:broadcast-table-rules>
+ </sharding:rule>
<!-- 配置ShardingSphereDataSource -->
- <sharding:data-source id="shardingDataSource">
- <!-- 配置分片规则 -->
- <sharding:sharding-rule data-source-names="ds0,ds1">
- <sharding:table-rules>
- <!-- 配置 t_order 表规则 -->
- <sharding:table-rule logic-table="t_order" actual-data-nodes="ds$->{0..1}.t_order$->{0..1}" database-strategy-ref="dbStrategy" table-strategy-ref="tableStrategy" />
- <!-- 省略配置 t_order_item 表规则... -->
- <!-- ... -->
- </sharding:table-rules>
- </sharding:sharding-rule>
- </sharding:data-source>
+ <shardingsphere:data-source id="shardingDataSource" data-source-names="ds0, ds1" rule-refs="shardingRule">
+ <props>
+ <prop key="sql-show">false</prop>
+ </props>
+ </shardingsphere:data-source>
+
</beans>
```
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/spring-namespace.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/spring-namespace.en.md
index 3b8ce4d..65b2ce8 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/spring-namespace.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/spring-namespace.en.md
@@ -43,32 +43,48 @@ weight = 4
<!-- Configure database sharding strategy -->
<sharding:sharding-algorithm id="dbShardingAlgorithm" type="INLINE">
- <properties>
- <prop key="algorithm-expression">ds$->{user_id % 2}</prop>
- </properties>
+ <props>
+ <prop key="algorithm-expression">ds$->{user_id % 2}</prop>
+ </props>
</sharding:sharding-algorithm>
<sharding:standard-strategy id="dbStrategy" sharding-column="user_id" algorithm-ref="dbShardingAlgorithm" />
-
+
<!-- Configure table sharding strategy -->
<sharding:sharding-algorithm id="tableShardingAlgorithm" type="INLINE">
- <properties>
- <prop key="algorithm-expression">t_order$->{order_id % 2}</prop>
- </properties>
+ <props>
+ <prop key="algorithm-expression">t_order$->{order_id % 2}</prop>
+ </props>
</sharding:sharding-algorithm>
<sharding:standard-strategy id="tableStrategy" sharding-column="user_id" algorithm-ref="tableShardingAlgorithm" />
-
+
+ <!-- Configure distributed key-generate strategy -->
+ <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
+ <props>
+ <prop key="worker-id">123</prop>
+ </props>
+ </sharding:key-generate-algorithm>
+ <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
+
+ <!-- Configure sharding rule -->
+ <sharding:rule id="shardingRule">
+ <sharding:table-rules>
+ <sharding:table-rule logic-table="t_order" actual-data-nodes="ds${0..1}.t_order_${0..1}" database-strategy-ref="dbStrategy" table-strategy-ref="tableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
+ </sharding:table-rules>
+ <sharding:binding-table-rules>
+ <sharding:binding-table-rule logic-tables="t_order,t_order_item"/>
+ </sharding:binding-table-rules>
+ <sharding:broadcast-table-rules>
+ <sharding:broadcast-table-rule table="t_address"/>
+ </sharding:broadcast-table-rules>
+ </sharding:rule>
+
<!-- Configure ShardingSphereDataSource -->
- <sharding:data-source id="shardingDataSource">
- <!-- Configure sharding rule -->
- <sharding:sharding-rule data-source-names="ds0,ds1">
- <sharding:table-rules>
- <!-- Configure t_order table rule -->
- <sharding:table-rule logic-table="t_order" actual-data-nodes="ds$->{0..1}.t_order$->{0..1}" database-strategy-ref="dbStrategy" table-strategy-ref="tableStrategy" />
- <!-- Omit t_order_item table rule configuration ... -->
- <!-- ... -->
- </sharding:table-rules>
- </sharding:sharding-rule>
- </sharding:data-source>
+ <shardingsphere:data-source id="shardingDataSource" data-source-names="ds0,ds1" rule-refs="shardingRule">
+ <props>
+ <prop key="sql-show">false</prop>
+ </props>
+ </shardingsphere:data-source>
+
</beans>
```