withNamespaceBindingTables.xml 1.8 KB
Newer Older
1 2 3
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
T
terrymanu 已提交
4
       xmlns:sharding="http://shardingjdbc.io/schema/shardingjdbc/sharding"
5 6
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                        http://www.springframework.org/schema/beans/spring-beans.xsd 
T
terrymanu 已提交
7 8
                        http://shardingjdbc.io/schema/shardingjdbc/sharding 
                        http://shardingjdbc.io/schema/shardingjdbc/sharding/sharding.xsd 
9
                        ">
10
    <import resource="datasource/dataSource.xml" />
T
terrymanu 已提交
11
    
T
terrymanu 已提交
12 13
    <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" precise-algorithm-class="io.shardingjdbc.spring.algorithm.PreciseModuloDatabaseShardingAlgorithm" />
    <sharding:standard-strategy id="tableStrategy" sharding-column="order_id" precise-algorithm-class="io.shardingjdbc.spring.algorithm.PreciseModuloTableShardingAlgorithm" />
T
terrymanu 已提交
14
    
T
terrymanu 已提交
15
    <sharding:data-source id="shardingDatasource">
T
terrymanu 已提交
16
        <sharding:sharding-rule data-source-names="dbtbl_0,dbtbl_1" default-data-source-name="dbtbl_0">
T
terrymanu 已提交
17
            <sharding:table-rules>
18 19
                <sharding:table-rule logic-table="t_order" actual-data-nodes="dbtbl_${0..1}.t_order_${0..3}" database-strategy-ref="databaseStrategy" table-strategy-ref="tableStrategy" />
                <sharding:table-rule logic-table="t_order_item" actual-data-nodes="dbtbl_${0..1}.t_order_item_${0..3}" database-strategy-ref="databaseStrategy" table-strategy-ref="tableStrategy" />
T
terrymanu 已提交
20 21
            </sharding:table-rules>
            <sharding:binding-table-rules>
T
terrymanu 已提交
22
                <sharding:binding-table-rule logic-tables="t_order, t_order_item" />
T
terrymanu 已提交
23 24 25
            </sharding:binding-table-rules>
        </sharding:sharding-rule>
    </sharding:data-source>
26
</beans>