1. 广播表实战
⼴播表概念
1. 指所有的分⽚数据源中都存在的表,表结构和表中的数据在每个数据库中均完全⼀致。
2. 适⽤于数据量不⼤且需要与海量数据的表进⾏关联查询的场景。
3. 例如:字典表、配置表。
注意
1. 分库分表中间件,对应的数据库字段,不能是sql的关键字
在2个库中分别进行表创建
CREATE TABLE `ad_config` (
`id` bigint unsigned NOT NULL COMMENT '主键id',
`config_key` varchar(1024) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '配置key',
`config_value` varchar(1024) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '配置value',
`type` varchar(128) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '类型',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_bin;
实体类
package com.dss.sharding.model;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("ad_config")
public class AdConfigDO {
private Long id;
private String configKey;
private String configValue;
private String type;
}
package com.dss.sharding.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dss.sharding.model.AdConfigDO;
public interface AdConfigMapper extends BaseMapper<AdConfigDO> {
}
新增配置项
#配置广播表
spring.shardingsphere.sharding.broadcast-tables=ad_config
spring.shardingsphere.sharding.tables.ad_config.key-generator.column=id
spring.shardingsphere.sharding.tables.ad_config.key-generator.type=SNOWFLAKE
测试
@Autowired
private AdConfigMapper adConfigMapper;
@Test
public void testSaveAdConfig(){
AdConfigDO adConfigDO = new AdConfigDO();
adConfigDO.setConfigKey("banner");
adConfigDO.setConfigValue("youkuaiyun.com");
adConfigDO.setType("adss");
adConfigMapper.insert(adConfigDO);
}
结论
广播表中的数据是完全一模一样的
2 ⽔平分库+⽔平分表配置
库表结构
1. 2个数据库、每个库2张表
需求
1. 插⼊订单数据,分布在不同的库和表上
操作
1. 参考第一章,建立两个库,两个库中各有2张订单表
分库分表配置
1. 分库规则 根据 user_id 进⾏分库
2. 分表规则 根据 product_order_id 订单号进⾏分表
完整的配置文件
spring.application.name=dss-sharding-jdbc
server.port=8080
# 打印执行的数据库以及语句
spring.shardingsphere.props.sql.show=true
# 数据源 db0
spring.shardingsphere.datasource.names=ds0,ds1
# 第一个数据库
spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds0.jdbc-url=jdbc:mysql://127.0.0.1:3306/xdclass_shop_order_0?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.shardingsphere.datasource.ds0.username=root
spring.shardingsphere.datasource.ds0.password=root
# 第二个数据库
spring.shardingsphere.datasource.ds1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds1.jdbc-url=jdbc:mysql://127.0.0.1:3306/xdclass_shop_order_1?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.shardingsphere.datasource.ds1.username=root
spring.shardingsphere.datasource.ds1.password=root
#配置workId
spring.shardingsphere.sharding.tables.product_order.key-generator.props.worker.id=1
#配置广播表
spring.shardingsphere.sharding.broadcast-tables=ad_config
spring.shardingsphere.sharding.tables.ad_config.key-generator.column=id
spring.shardingsphere.sharding.tables.ad_config.key-generator.type=SNOWFLAKE
#配置分库规则
spring.shardingsphere.sharding.tables.product_order.database-strategy.inline.sharding-column=user_id
spring.shardingsphere.sharding.tables.product_order.database-strategy.inline.algorithm-expression=ds$->{user_id % 2 }
#id生成策略
spring.shardingsphere.sharding.tables.product_order.key-generator.column=id
spring.shardingsphere.sharding.tables.product_order.key-generator.type=SNOWFLAKE
# 指定product_order表的数据分布情况,配置数据节点,行表达式标识符使用 ${...} 或 $->{...},
# 但前者与 Spring 本身的文件占位符冲突,所以在 Spring 环境中建议使用 $->{...}
#spring.shardingsphere.sharding.tables.product_order.actual-data-nodes=ds0.product_order_$->{0..1}
spring.shardingsphere.sharding.tables.product_order.actual-data-nodes=ds$->{0..1}.product_order_$->{0..1}
# 指定product_order表的分片策略,分片策略包括【分片键和分片算法】
spring.shardingsphere.sharding.tables.product_order.table-strategy.inline.sharding-column=id
spring.shardingsphere.sharding.tables.product_order.table-strategy.inline.algorithm-expression=product_order_$->{id % 2}
测试类
@Test
public void testSaveProductOrder2(){
Random random = new Random();
for(int i=0; i<20;i++){
ProductOrderDO productOrderDO = new ProductOrderDO();
productOrderDO.setCreateTime(new Date());
productOrderDO.setNickname("dss_i="+i);
productOrderDO.setOutTradeNo(UUID.randomUUID().toString().substring(0,32));
productOrderDO.setPayAmount(100.00);
productOrderDO.setState("PAY");
/**
* userid需要实时生成
*/
productOrderDO.setUserId( Long.valueOf(random.nextInt(50)) );
productOrderMapper.insert(productOrderDO);
}
}
测试效果
1. 共计20条数据,分别落在2各库中的2各表中。
2. 4张表的数据量分别是6,6,6,2条
3.绑定表介绍和配置实战
绑定表
1. 指分⽚规则⼀致的主表和⼦表
建立子表
CREATE TABLE `product_order_item_0` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`product_order_id` bigint DEFAULT NULL COMMENT '订单号',
`product_id` bigint DEFAULT NULL COMMENT '产品id',
`product_name` varchar(128) DEFAULT NULL COMMENT'商品名称',
`buy_num` int DEFAULT NULL COMMENT '购买数量',
`user_id` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT
CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
注意: 在两个库中,分别创建各自的明细表,效果如图:
配置项
spring.application.name=sharding-jdbc
server.port=8080
# 打印执行的数据库以及语句
spring.shardingsphere.props.sql.show=true
# 数据源 db0
spring.shardingsphere.datasource.names=ds0,ds1
# 第一个数据库
spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds0.jdbc-url=jdbc:mysql://127.0.0.1:3306/xdclass_shop_order_0?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.shardingsphere.datasource.ds0.username=root
spring.shardingsphere.datasource.ds0.password=root
# 第二个数据库
spring.shardingsphere.datasource.ds1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds1.jdbc-url=jdbc:mysql://127.0.0.1:3306/xdclass_shop_order_1?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.shardingsphere.datasource.ds1.username=root
spring.shardingsphere.datasource.ds1.password=root
#配置workId
spring.shardingsphere.sharding.tables.product_order.key-generator.props.worker.id=1
#配置广播表
spring.shardingsphere.sharding.broadcast-tables=ad_config
spring.shardingsphere.sharding.tables.ad_config.key-generator.column=id
spring.shardingsphere.sharding.tables.ad_config.key-generator.type=SNOWFLAKE
#配置【默认分库策略】
spring.shardingsphere.sharding.default-database-strategy.inline.sharding-column=user_id
spring.shardingsphere.sharding.default-database-strategy.inline.algorithm-expression=ds$->{user_id % 2 }
#配置分库规则
spring.shardingsphere.sharding.tables.product_order.database-strategy.inline.sharding-column=user_id
spring.shardingsphere.sharding.tables.product_order.database-strategy.inline.algorithm-expression=ds$->{user_id % 2 }
#id生成策略
spring.shardingsphere.sharding.tables.product_order.key-generator.column=id
spring.shardingsphere.sharding.tables.product_order.key-generator.type=SNOWFLAKE
# 指定product_order表的数据分布情况,配置数据节点,行表达式标识符使用 ${...} 或 $->{...},
# 但前者与 Spring 本身的文件占位符冲突,所以在 Spring 环境中建议使用 $->{...}
#spring.shardingsphere.sharding.tables.product_order.actual-data-nodes=ds0.product_order_$->{0..1}
spring.shardingsphere.sharding.tables.product_order.actual-data-nodes=ds$->{0..1}.product_order_$->{0..1}
# 指定product_order表的分片策略,分片策略包括【分片键和分片算法】
spring.shardingsphere.sharding.tables.product_order.table-strategy.inline.sharding-column=id
spring.shardingsphere.sharding.tables.product_order.table-strategy.inline.algorithm-expression=product_order_$->{id % 2}
# 指定product_order_item表的分片策略,分片策略包括【分片键和分片算法】
spring.shardingsphere.sharding.tables.product_order_item.actual-data-nodes=ds$->{0..1}.product_order_item_$->{0..1}
spring.shardingsphere.sharding.tables.product_order_item.table-strategy.inline.sharding-column=product_order_id
spring.shardingsphere.sharding.tables.product_order_item.table-strategy.inline.algorithm-expression=product_order_item_$->{product_order_id % 2}
#配置绑定表,每个库中的主表和对应的库中的明细表进行关联,如果不配置会出现笛卡尔集的情况
spring.shardingsphere.sharding.binding‐tables[0] = product_order,product_order_item
package com.dss.sharding.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dss.sharding.model.ProductOrderItemDO;
public interface ProductOrderItemMapper extends BaseMapper<ProductOrderItemDO> {
}
查询
package com.dss.sharding.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dss.sharding.model.ProductOrderDO;
import org.apache.ibatis.annotations.Select;
public interface ProductOrderMapper extends BaseMapper<ProductOrderDO> {
@Select("select * from product_order o left join product_order_item i on o.id=i.product_order_id")
List<Object> listProductOrderDetail();
}
@Test
public void testBingding(){
List<Object> list = productOrderMapper.listProductOrderDetail();
System.out.println(list);
}
sql的输出结果,可以得出各自库中的关联查询
"C:\Program Files\Java\jdk1.8.0_152\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:51047,suspend=y,server=n -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\92340\AppData\Local\JetBrains\IntelliJIdea2021.2\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "D:\Program Files\JetBrains\IntelliJ IDEA 2021.2.1\lib\idea_rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2021.2.1\plugins\junit\lib\junit5-rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2021.2.1\plugins\junit\lib\junit-rt.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\rt.jar;D:\msb\sharding\target\test-classes;D:\msb\sharding\target\classes;D:\mvnrepository\org\springframework\boot\spring-boot-starter-web\2.5.5\spring-boot-starter-web-2.5.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter\2.5.5\spring-boot-starter-2.5.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot\2.5.5\spring-boot-2.5.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter-logging\2.5.5\spring-boot-starter-logging-2.5.5.jar;D:\mvnrepository\ch\qos\logback\logback-classic\1.2.6\logback-classic-1.2.6.jar;D:\mvnrepository\ch\qos\logback\logback-core\1.2.6\logback-core-1.2.6.jar;D:\mvnrepository\org\apache\logging\log4j\log4j-to-slf4j\2.14.1\log4j-to-slf4j-2.14.1.jar;D:\mvnrepository\org\apache\logging\log4j\log4j-api\2.14.1\log4j-api-2.14.1.jar;D:\mvnrepository\org\slf4j\jul-to-slf4j\1.7.32\jul-to-slf4j-1.7.32.jar;D:\mvnrepository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;D:\mvnrepository\org\yaml\snakeyaml\1.28\snakeyaml-1.28.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter-json\2.5.5\spring-boot-starter-json-2.5.5.jar;D:\mvnrepository\com\fasterxml\jackson\core\jackson-databind\2.12.5\jackson-databind-2.12.5.jar;D:\mvnrepository\com\fasterxml\jackson\core\jackson-annotations\2.12.5\jackson-annotations-2.12.5.jar;D:\mvnrepository\com\fasterxml\jackson\core\jackson-core\2.12.5\jackson-core-2.12.5.jar;D:\mvnrepository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.12.5\jackson-datatype-jdk8-2.12.5.jar;D:\mvnrepository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.12.5\jackson-datatype-jsr310-2.12.5.jar;D:\mvnrepository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.12.5\jackson-module-parameter-names-2.12.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter-tomcat\2.5.5\spring-boot-starter-tomcat-2.5.5.jar;D:\mvnrepository\org\apache\tomcat\embed\tomcat-embed-core\9.0.53\tomcat-embed-core-9.0.53.jar;D:\mvnrepository\org\apache\tomcat\embed\tomcat-embed-el\9.0.53\tomcat-embed-el-9.0.53.jar;D:\mvnrepository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.53\tomcat-embed-websocket-9.0.53.jar;D:\mvnrepository\org\springframework\spring-web\5.3.10\spring-web-5.3.10.jar;D:\mvnrepository\org\springframework\spring-beans\5.3.10\spring-beans-5.3.10.jar;D:\mvnrepository\org\springframework\spring-webmvc\5.3.10\spring-webmvc-5.3.10.jar;D:\mvnrepository\org\springframework\spring-aop\5.3.10\spring-aop-5.3.10.jar;D:\mvnrepository\org\springframework\spring-context\5.3.10\spring-context-5.3.10.jar;D:\mvnrepository\org\springframework\spring-expression\5.3.10\spring-expression-5.3.10.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter-test\2.5.5\spring-boot-starter-test-2.5.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-test\2.5.5\spring-boot-test-2.5.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-test-autoconfigure\2.5.5\spring-boot-test-autoconfigure-2.5.5.jar;D:\mvnrepository\com\jayway\jsonpath\json-path\2.5.0\json-path-2.5.0.jar;D:\mvnrepository\net\minidev\json-smart\2.3\json-smart-2.3.jar;D:\mvnrepository\net\minidev\accessors-smart\1.2\accessors-smart-1.2.jar;D:\mvnrepository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;D:\mvnrepository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;D:\mvnrepository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;D:\mvnrepository\org\assertj\assertj-core\3.19.0\assertj-core-3.19.0.jar;D:\mvnrepository\org\hamcrest\hamcrest\2.2\hamcrest-2.2.jar;D:\mvnrepository\org\junit\jupiter\junit-jupiter\5.7.2\junit-jupiter-5.7.2.jar;D:\mvnrepository\org\junit\jupiter\junit-jupiter-api\5.7.2\junit-jupiter-api-5.7.2.jar;D:\mvnrepository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;D:\mvnrepository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;D:\mvnrepository\org\junit\platform\junit-platform-commons\1.7.2\junit-platform-commons-1.7.2.jar;D:\mvnrepository\org\junit\jupiter\junit-jupiter-params\5.7.2\junit-jupiter-params-5.7.2.jar;D:\mvnrepository\org\junit\jupiter\junit-jupiter-engine\5.7.2\junit-jupiter-engine-5.7.2.jar;D:\mvnrepository\org\junit\platform\junit-platform-engine\1.7.2\junit-platform-engine-1.7.2.jar;D:\mvnrepository\org\mockito\mockito-core\3.9.0\mockito-core-3.9.0.jar;D:\mvnrepository\net\bytebuddy\byte-buddy\1.10.20\byte-buddy-1.10.20.jar;D:\mvnrepository\net\bytebuddy\byte-buddy-agent\1.10.20\byte-buddy-agent-1.10.20.jar;D:\mvnrepository\org\objenesis\objenesis\3.2\objenesis-3.2.jar;D:\mvnrepository\org\mockito\mockito-junit-jupiter\3.9.0\mockito-junit-jupiter-3.9.0.jar;D:\mvnrepository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;D:\mvnrepository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;D:\mvnrepository\org\springframework\spring-core\5.3.10\spring-core-5.3.10.jar;D:\mvnrepository\org\springframework\spring-jcl\5.3.10\spring-jcl-5.3.10.jar;D:\mvnrepository\org\springframework\spring-test\5.3.10\spring-test-5.3.10.jar;D:\mvnrepository\org\xmlunit\xmlunit-core\2.8.2\xmlunit-core-2.8.2.jar;D:\mvnrepository\com\baomidou\mybatis-plus-boot-starter\3.4.0\mybatis-plus-boot-starter-3.4.0.jar;D:\mvnrepository\com\baomidou\mybatis-plus\3.4.0\mybatis-plus-3.4.0.jar;D:\mvnrepository\com\baomidou\mybatis-plus-extension\3.4.0\mybatis-plus-extension-3.4.0.jar;D:\mvnrepository\com\baomidou\mybatis-plus-core\3.4.0\mybatis-plus-core-3.4.0.jar;D:\mvnrepository\com\baomidou\mybatis-plus-annotation\3.4.0\mybatis-plus-annotation-3.4.0.jar;D:\mvnrepository\com\github\jsqlparser\jsqlparser\3.2\jsqlparser-3.2.jar;D:\mvnrepository\org\mybatis\mybatis\3.5.5\mybatis-3.5.5.jar;D:\mvnrepository\org\mybatis\mybatis-spring\2.0.5\mybatis-spring-2.0.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-autoconfigure\2.3.2.RELEASE\spring-boot-autoconfigure-2.3.2.RELEASE.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter-jdbc\2.3.2.RELEASE\spring-boot-starter-jdbc-2.3.2.RELEASE.jar;D:\mvnrepository\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;D:\mvnrepository\org\springframework\spring-jdbc\5.2.8.RELEASE\spring-jdbc-5.2.8.RELEASE.jar;D:\mvnrepository\org\springframework\spring-tx\5.2.8.RELEASE\spring-tx-5.2.8.RELEASE.jar;D:\mvnrepository\mysql\mysql-connector-java\8.0.27\mysql-connector-java-8.0.27.jar;D:\mvnrepository\com\google\protobuf\protobuf-java\3.11.4\protobuf-java-3.11.4.jar;D:\mvnrepository\org\projectlombok\lombok\1.18.16\lombok-1.18.16.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-jdbc-spring-boot-starter\4.1.1\sharding-jdbc-spring-boot-starter-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-spring-boot-util\4.1.1\sharding-spring-boot-util-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-common\4.1.1\sharding-core-common-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-common\4.1.1\shardingsphere-common-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-spi\4.1.1\shardingsphere-spi-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-binder\4.1.1\shardingsphere-sql-parser-binder-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-api\4.1.1\sharding-core-api-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\encrypt-core-api\4.1.1\encrypt-core-api-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\encrypt-core-common\4.1.1\encrypt-core-common-4.1.1.jar;D:\mvnrepository\org\codehaus\groovy\groovy\2.4.5\groovy-2.4.5-indy.jar;D:\mvnrepository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-transaction-spring\4.1.1\sharding-transaction-spring-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-transaction-core\4.1.1\sharding-transaction-core-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-jdbc-core\4.1.1\sharding-jdbc-core-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-pluggable\4.1.1\shardingsphere-pluggable-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-route\4.1.1\shardingsphere-route-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-rewrite-engine\4.1.1\shardingsphere-rewrite-engine-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-executor\4.1.1\shardingsphere-executor-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-merge\4.1.1\shardingsphere-merge-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-sql92\4.1.1\shardingsphere-sql-parser-sql92-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-engine\4.1.1\shardingsphere-sql-parser-engine-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-spi\4.1.1\shardingsphere-sql-parser-spi-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-statement\4.1.1\shardingsphere-sql-parser-statement-4.1.1.jar;D:\mvnrepository\org\apache\commons\commons-collections4\4.2\commons-collections4-4.2.jar;D:\mvnrepository\org\antlr\antlr4-runtime\4.7.2\antlr4-runtime-4.7.2.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-mysql\4.1.1\shardingsphere-sql-parser-mysql-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-postgresql\4.1.1\shardingsphere-sql-parser-postgresql-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-oracle\4.1.1\shardingsphere-sql-parser-oracle-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-sqlserver\4.1.1\shardingsphere-sql-parser-sqlserver-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-route\4.1.1\sharding-core-route-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\master-slave-core-route\4.1.1\master-slave-core-route-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-rewrite\4.1.1\sharding-core-rewrite-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\encrypt-core-rewrite\4.1.1\encrypt-core-rewrite-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shadow-core-rewrite\4.1.1\shadow-core-rewrite-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-execute\4.1.1\sharding-core-execute-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-merge\4.1.1\sharding-core-merge-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\encrypt-core-merge\4.1.1\encrypt-core-merge-4.1.1.jar;D:\mvnrepository\com\google\guava\guava\18.0\guava-18.0.jar;D:\mvnrepository\org\slf4j\slf4j-api\1.7.7\slf4j-api-1.7.7.jar;D:\mvnrepository\org\slf4j\jcl-over-slf4j\1.7.7\jcl-over-slf4j-1.7.7.jar;D:\mvnrepository\junit\junit\4.12\junit-4.12.jar;D:\mvnrepository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 dss.nq.db.ShardingTest,testBingding
Connected to the target VM, address: '127.0.0.1:51047', transport: 'socket'
20:27:06.687 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class dss.nq.db.ShardingTest]
20:27:06.704 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
20:27:06.755 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
20:27:07.003 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [dss.nq.db.ShardingTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
20:27:07.118 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [dss.nq.db.ShardingTest], using SpringBootContextLoader
20:27:07.159 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [dss.nq.db.ShardingTest]: class path resource [dss/nq/db/ShardingTest-context.xml] does not exist
20:27:07.165 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [dss.nq.db.ShardingTest]: class path resource [dss/nq/db/ShardingTestContext.groovy] does not exist
20:27:07.168 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [dss.nq.db.ShardingTest]: no resource found for suffixes {-context.xml, Context.groovy}.
20:27:07.478 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [dss.nq.db.ShardingTest]
20:27:08.261 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [dss.nq.db.ShardingTest]: using defaults.
20:27:08.268 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
20:27:08.360 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@6f8e8894, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@3cfdd820, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@928763c, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@e25951c, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@15f47664, org.springframework.test.context.support.DirtiesContextTestExecutionListener@471a9022, org.springframework.test.context.transaction.TransactionalTestExecutionListener@dc9876b, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@2f666ebb, org.springframework.test.context.event.EventPublishingTestExecutionListener@19976a65, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@a1f72f5, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@4b2c5e02, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@57a3e26a, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@75c56eb9, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@4bc222e, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@2dc9b0f5]
20:27:08.371 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [dss.nq.db.ShardingTest]
20:27:08.379 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [dss.nq.db.ShardingTest]
20:27:08.424 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [dss.nq.db.ShardingTest]
20:27:08.425 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [dss.nq.db.ShardingTest]
20:27:08.431 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [dss.nq.db.ShardingTest]
20:27:08.432 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [dss.nq.db.ShardingTest]
20:27:08.434 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [dss.nq.db.ShardingTest]
20:27:08.435 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [dss.nq.db.ShardingTest]
20:27:08.453 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@7354b8c5 testClass = ShardingTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@20d7d6fb testClass = ShardingTest, locations = '{}', classes = '{class com.dss.sharding.Application}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@fbd1f6, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@7a8c8dcf, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@43c1b556, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@305b7c14, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@26b3fd41, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@402bba4f], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
20:27:08.460 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [dss.nq.db.ShardingTest]
20:27:08.460 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [dss.nq.db.ShardingTest]
20:27:08.636 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.5)
2024-11-13 20:27:11.637 INFO 15748 --- [ main] dss.nq.db.ShardingTest : Starting ShardingTest using Java 1.8.0_152 on DESKTOP-55SE7QS with PID 15748 (started by 92340 in D:\msb\sharding)
2024-11-13 20:27:11.649 INFO 15748 --- [ main] dss.nq.db.ShardingTest : No active profile set, falling back to default profiles: default
2024-11-13 20:27:15.657 INFO 15748 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'stringToNoneShardingStrategyConfigurationConverter' of type [org.apache.shardingsphere.spring.boot.converter.StringToNoneShardingStrategyConfigurationConverter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-13 20:27:15.894 INFO 15748 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.shardingsphere.sharding-org.apache.shardingsphere.shardingjdbc.spring.boot.sharding.SpringBootShardingRuleConfigurationProperties' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.sharding.SpringBootShardingRuleConfigurationProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-13 20:27:15.913 INFO 15748 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.shardingsphere.masterslave-org.apache.shardingsphere.shardingjdbc.spring.boot.masterslave.SpringBootMasterSlaveRuleConfigurationProperties' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.masterslave.SpringBootMasterSlaveRuleConfigurationProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-13 20:27:15.931 INFO 15748 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.shardingsphere.encrypt-org.apache.shardingsphere.shardingjdbc.spring.boot.encrypt.SpringBootEncryptRuleConfigurationProperties' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.encrypt.SpringBootEncryptRuleConfigurationProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-13 20:27:15.957 INFO 15748 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.shardingsphere.shadow-org.apache.shardingsphere.shardingjdbc.spring.boot.shadow.SpringBootShadowRuleConfigurationProperties' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.shadow.SpringBootShadowRuleConfigurationProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-13 20:27:15.967 INFO 15748 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.shardingsphere-org.apache.shardingsphere.shardingjdbc.spring.boot.common.SpringBootPropertiesConfigurationProperties' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.common.SpringBootPropertiesConfigurationProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-13 20:27:17.194 INFO 15748 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration$$EnhancerBySpringCGLIB$$9da2a210] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-13 20:27:21.146 INFO 15748 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2024-11-13 20:27:22.017 INFO 15748 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2024-11-13 20:27:22.088 INFO 15748 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Starting...
2024-11-13 20:27:22.105 INFO 15748 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Start completed.
2024-11-13 20:27:22.740 INFO 15748 --- [ main] o.a.s.core.log.ConfigurationLogger : ShardingRuleConfiguration:
bindingTables:
- product_order,product_order_item
broadcastTables:
- ad_config
defaultDatabaseStrategy:
inline:
algorithmExpression: ds$->{user_id % 2 }
shardingColumn: user_id
tables:
product_order:
actualDataNodes: ds$->{0..1}.product_order_$->{0..1}
databaseStrategy:
inline:
algorithmExpression: ds$->{user_id % 2 }
shardingColumn: user_id
keyGenerator:
column: id
props:
worker.id: '1'
type: SNOWFLAKE
logicTable: product_order
tableStrategy:
inline:
algorithmExpression: product_order_$->{id % 2}
shardingColumn: id
ad_config:
keyGenerator:
column: id
type: SNOWFLAKE
logicTable: ad_config
product_order_item:
actualDataNodes: ds$->{0..1}.product_order_item_$->{0..1}
logicTable: product_order_item
tableStrategy:
inline:
algorithmExpression: product_order_item_$->{product_order_id % 2}
shardingColumn: product_order_id
2024-11-13 20:27:22.742 INFO 15748 --- [ main] o.a.s.core.log.ConfigurationLogger : Properties:
sql.show: 'true'
2024-11-13 20:27:22.842 INFO 15748 --- [ main] ShardingSphere-metadata : Loading 3 logic tables' meta data.
2024-11-13 20:27:23.075 INFO 15748 --- [ main] ShardingSphere-metadata : Meta data load finished, cost 332 milliseconds.
_ _ |_ _ _|_. ___ _ | _
| | |\/|_)(_| | |_\ |_)||_|_\
/ |
3.4.0
2024-11-13 20:27:27.917 INFO 15748 --- [ main] dss.nq.db.ShardingTest : Started ShardingTest in 19.235 seconds (JVM running for 23.587)
2024-11-13 20:27:30.404 INFO 15748 --- [ main] ShardingSphere-SQL : Logic SQL: select * from product_order o left join product_order_item i on o.id=i.product_order_id
2024-11-13 20:27:30.404 INFO 15748 --- [ main] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@2ccecae2, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@37ade216), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@37ade216, projectionsContext=ProjectionsContext(startIndex=7, stopIndex=7, distinctRow=false, projections=[ShorthandProjection(owner=Optional.empty, actualColumns=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=out_trade_no, alias=Optional.empty), ColumnProjection(owner=null, name=state, alias=Optional.empty), ColumnProjection(owner=null, name=create_time, alias=Optional.empty), ColumnProjection(owner=null, name=pay_amount, alias=Optional.empty), ColumnProjection(owner=null, name=nickname, alias=Optional.empty), ColumnProjection(owner=null, name=user_id, alias=Optional.empty), ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=product_order_id, alias=Optional.empty), ColumnProjection(owner=null, name=product_id, alias=Optional.empty), ColumnProjection(owner=null, name=product_name, alias=Optional.empty), ColumnProjection(owner=null, name=buy_num, alias=Optional.empty), ColumnProjection(owner=null, name=user_id, alias=Optional.empty)])]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@118e2487, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@6032622, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@5cc075da, containsSubquery=false)
2024-11-13 20:27:30.405 INFO 15748 --- [ main] ShardingSphere-SQL : Actual SQL: ds0 ::: select * from product_order_0 o left join product_order_item_0 i on o.id=i.product_order_id
2024-11-13 20:27:30.405 INFO 15748 --- [ main] ShardingSphere-SQL : Actual SQL: ds0 ::: select * from product_order_1 o left join product_order_item_1 i on o.id=i.product_order_id
2024-11-13 20:27:30.405 INFO 15748 --- [ main] ShardingSphere-SQL : Actual SQL: ds1 ::: select * from product_order_0 o left join product_order_item_0 i on o.id=i.product_order_id
2024-11-13 20:27:30.405 INFO 15748 --- [ main] ShardingSphere-SQL : Actual SQL: ds1 ::: select * from product_order_1 o left join product_order_item_1 i on o.id=i.product_order_id
[1856174867678306306, 1856174867942547458, 1856174868001267714, 1856174868068376578, 1856174868647190530, 1856174869163089922, 1856174867745415169, 1856174867875438593, 1856174868324229121, 1856174868395532289, 1856174868789796865, 1856174869100175361, 1856174861005168642, 1856174868131291138, 1856174868462641154, 1856174868580081666, 1856174868718493698, 1856174868965957634, 1856174868252925953, 1856174868907237377]
2024-11-13 20:27:30.601 INFO 15748 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2024-11-13 20:27:30.649 INFO 15748 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2024-11-13 20:27:30.649 INFO 15748 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown initiated...
2024-11-13 20:27:30.665 INFO 15748 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown completed.
Disconnected from the target VM, address: '127.0.0.1:51047', transport: 'socket'
Process finished with exit code 0
4. Sharding-Jdbc⽔平分库+分表后的查询和删除操作
/**
* 有分片键
* 虽然会向两个库发出查询语句,但是会根据查询条件命中对应库的对应表
*/
@Test
public void testPartitionKeySelect(){
productOrderMapper.selectList(new QueryWrapper<ProductOrderDO>().eq("id",1464129579089227778L));
//productOrderMapper.selectList(new QueryWrapper<ProductOrderDO>().in("id",Arrays.asList(1464129579089227778L,1464129582369173506L,1464129583140925441L)));
}
/**
* 无有分片键,会全库进行查找
*/
@Test
public void testNoPartitionKeySelect(){
productOrderMapper.selectList(new QueryWrapper<ProductOrderDO>().eq("out_trade_no","2cc08fb8-7e77-4973-b408-7c68925b"));
//productOrderMapper.selectList(new QueryWrapper<ProductOrderDO>().in("out_trade_no",Arrays.asList("2cc08fb8-7e77-4973-b408-7c68925b")));
}
/**
* 有分片键
*/
@Test
public void testPartitionKeyDel(){
//productOrderMapper.delete(new QueryWrapper<ProductOrderDO>().eq("id",1464129579089227778L));
//productOrderMapper.delete(new QueryWrapper<ProductOrderDO>().in("id",Arrays.asList(1464129579089227778L,1464129582369173506L,1464129583140925441L)));
}
/**
* 无有分片键
*/
@Test
public void testNoPartitionKeyDel(){
//productOrderMapper.delete(new QueryWrapper<ProductOrderDO>().eq("out_trade_no","2cc08fb8-7e77-4973-b408-7c68925b"));
productOrderMapper.delete(new QueryWrapper<ProductOrderDO>().in("out_trade_no",Arrays.asList("2cc08fb8-7e77-4973-b408-7c68925b")));
}
"C:\Program Files\Java\jdk1.8.0_152\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:64216,suspend=y,server=n -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\92340\AppData\Local\JetBrains\IntelliJIdea2021.2\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "D:\Program Files\JetBrains\IntelliJ IDEA 2021.2.1\lib\idea_rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2021.2.1\plugins\junit\lib\junit5-rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2021.2.1\plugins\junit\lib\junit-rt.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\rt.jar;D:\msb\sharding\target\test-classes;D:\msb\sharding\target\classes;D:\mvnrepository\org\springframework\boot\spring-boot-starter-web\2.5.5\spring-boot-starter-web-2.5.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter\2.5.5\spring-boot-starter-2.5.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot\2.5.5\spring-boot-2.5.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter-logging\2.5.5\spring-boot-starter-logging-2.5.5.jar;D:\mvnrepository\ch\qos\logback\logback-classic\1.2.6\logback-classic-1.2.6.jar;D:\mvnrepository\ch\qos\logback\logback-core\1.2.6\logback-core-1.2.6.jar;D:\mvnrepository\org\apache\logging\log4j\log4j-to-slf4j\2.14.1\log4j-to-slf4j-2.14.1.jar;D:\mvnrepository\org\apache\logging\log4j\log4j-api\2.14.1\log4j-api-2.14.1.jar;D:\mvnrepository\org\slf4j\jul-to-slf4j\1.7.32\jul-to-slf4j-1.7.32.jar;D:\mvnrepository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;D:\mvnrepository\org\yaml\snakeyaml\1.28\snakeyaml-1.28.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter-json\2.5.5\spring-boot-starter-json-2.5.5.jar;D:\mvnrepository\com\fasterxml\jackson\core\jackson-databind\2.12.5\jackson-databind-2.12.5.jar;D:\mvnrepository\com\fasterxml\jackson\core\jackson-annotations\2.12.5\jackson-annotations-2.12.5.jar;D:\mvnrepository\com\fasterxml\jackson\core\jackson-core\2.12.5\jackson-core-2.12.5.jar;D:\mvnrepository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.12.5\jackson-datatype-jdk8-2.12.5.jar;D:\mvnrepository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.12.5\jackson-datatype-jsr310-2.12.5.jar;D:\mvnrepository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.12.5\jackson-module-parameter-names-2.12.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter-tomcat\2.5.5\spring-boot-starter-tomcat-2.5.5.jar;D:\mvnrepository\org\apache\tomcat\embed\tomcat-embed-core\9.0.53\tomcat-embed-core-9.0.53.jar;D:\mvnrepository\org\apache\tomcat\embed\tomcat-embed-el\9.0.53\tomcat-embed-el-9.0.53.jar;D:\mvnrepository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.53\tomcat-embed-websocket-9.0.53.jar;D:\mvnrepository\org\springframework\spring-web\5.3.10\spring-web-5.3.10.jar;D:\mvnrepository\org\springframework\spring-beans\5.3.10\spring-beans-5.3.10.jar;D:\mvnrepository\org\springframework\spring-webmvc\5.3.10\spring-webmvc-5.3.10.jar;D:\mvnrepository\org\springframework\spring-aop\5.3.10\spring-aop-5.3.10.jar;D:\mvnrepository\org\springframework\spring-context\5.3.10\spring-context-5.3.10.jar;D:\mvnrepository\org\springframework\spring-expression\5.3.10\spring-expression-5.3.10.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter-test\2.5.5\spring-boot-starter-test-2.5.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-test\2.5.5\spring-boot-test-2.5.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-test-autoconfigure\2.5.5\spring-boot-test-autoconfigure-2.5.5.jar;D:\mvnrepository\com\jayway\jsonpath\json-path\2.5.0\json-path-2.5.0.jar;D:\mvnrepository\net\minidev\json-smart\2.3\json-smart-2.3.jar;D:\mvnrepository\net\minidev\accessors-smart\1.2\accessors-smart-1.2.jar;D:\mvnrepository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;D:\mvnrepository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;D:\mvnrepository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;D:\mvnrepository\org\assertj\assertj-core\3.19.0\assertj-core-3.19.0.jar;D:\mvnrepository\org\hamcrest\hamcrest\2.2\hamcrest-2.2.jar;D:\mvnrepository\org\junit\jupiter\junit-jupiter\5.7.2\junit-jupiter-5.7.2.jar;D:\mvnrepository\org\junit\jupiter\junit-jupiter-api\5.7.2\junit-jupiter-api-5.7.2.jar;D:\mvnrepository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;D:\mvnrepository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;D:\mvnrepository\org\junit\platform\junit-platform-commons\1.7.2\junit-platform-commons-1.7.2.jar;D:\mvnrepository\org\junit\jupiter\junit-jupiter-params\5.7.2\junit-jupiter-params-5.7.2.jar;D:\mvnrepository\org\junit\jupiter\junit-jupiter-engine\5.7.2\junit-jupiter-engine-5.7.2.jar;D:\mvnrepository\org\junit\platform\junit-platform-engine\1.7.2\junit-platform-engine-1.7.2.jar;D:\mvnrepository\org\mockito\mockito-core\3.9.0\mockito-core-3.9.0.jar;D:\mvnrepository\net\bytebuddy\byte-buddy\1.10.20\byte-buddy-1.10.20.jar;D:\mvnrepository\net\bytebuddy\byte-buddy-agent\1.10.20\byte-buddy-agent-1.10.20.jar;D:\mvnrepository\org\objenesis\objenesis\3.2\objenesis-3.2.jar;D:\mvnrepository\org\mockito\mockito-junit-jupiter\3.9.0\mockito-junit-jupiter-3.9.0.jar;D:\mvnrepository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;D:\mvnrepository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;D:\mvnrepository\org\springframework\spring-core\5.3.10\spring-core-5.3.10.jar;D:\mvnrepository\org\springframework\spring-jcl\5.3.10\spring-jcl-5.3.10.jar;D:\mvnrepository\org\springframework\spring-test\5.3.10\spring-test-5.3.10.jar;D:\mvnrepository\org\xmlunit\xmlunit-core\2.8.2\xmlunit-core-2.8.2.jar;D:\mvnrepository\com\baomidou\mybatis-plus-boot-starter\3.4.0\mybatis-plus-boot-starter-3.4.0.jar;D:\mvnrepository\com\baomidou\mybatis-plus\3.4.0\mybatis-plus-3.4.0.jar;D:\mvnrepository\com\baomidou\mybatis-plus-extension\3.4.0\mybatis-plus-extension-3.4.0.jar;D:\mvnrepository\com\baomidou\mybatis-plus-core\3.4.0\mybatis-plus-core-3.4.0.jar;D:\mvnrepository\com\baomidou\mybatis-plus-annotation\3.4.0\mybatis-plus-annotation-3.4.0.jar;D:\mvnrepository\com\github\jsqlparser\jsqlparser\3.2\jsqlparser-3.2.jar;D:\mvnrepository\org\mybatis\mybatis\3.5.5\mybatis-3.5.5.jar;D:\mvnrepository\org\mybatis\mybatis-spring\2.0.5\mybatis-spring-2.0.5.jar;D:\mvnrepository\org\springframework\boot\spring-boot-autoconfigure\2.3.2.RELEASE\spring-boot-autoconfigure-2.3.2.RELEASE.jar;D:\mvnrepository\org\springframework\boot\spring-boot-starter-jdbc\2.3.2.RELEASE\spring-boot-starter-jdbc-2.3.2.RELEASE.jar;D:\mvnrepository\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;D:\mvnrepository\org\springframework\spring-jdbc\5.2.8.RELEASE\spring-jdbc-5.2.8.RELEASE.jar;D:\mvnrepository\org\springframework\spring-tx\5.2.8.RELEASE\spring-tx-5.2.8.RELEASE.jar;D:\mvnrepository\mysql\mysql-connector-java\8.0.27\mysql-connector-java-8.0.27.jar;D:\mvnrepository\com\google\protobuf\protobuf-java\3.11.4\protobuf-java-3.11.4.jar;D:\mvnrepository\org\projectlombok\lombok\1.18.16\lombok-1.18.16.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-jdbc-spring-boot-starter\4.1.1\sharding-jdbc-spring-boot-starter-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-spring-boot-util\4.1.1\sharding-spring-boot-util-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-common\4.1.1\sharding-core-common-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-common\4.1.1\shardingsphere-common-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-spi\4.1.1\shardingsphere-spi-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-binder\4.1.1\shardingsphere-sql-parser-binder-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-api\4.1.1\sharding-core-api-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\encrypt-core-api\4.1.1\encrypt-core-api-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\encrypt-core-common\4.1.1\encrypt-core-common-4.1.1.jar;D:\mvnrepository\org\codehaus\groovy\groovy\2.4.5\groovy-2.4.5-indy.jar;D:\mvnrepository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-transaction-spring\4.1.1\sharding-transaction-spring-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-transaction-core\4.1.1\sharding-transaction-core-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-jdbc-core\4.1.1\sharding-jdbc-core-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-pluggable\4.1.1\shardingsphere-pluggable-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-route\4.1.1\shardingsphere-route-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-rewrite-engine\4.1.1\shardingsphere-rewrite-engine-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-executor\4.1.1\shardingsphere-executor-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-merge\4.1.1\shardingsphere-merge-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-sql92\4.1.1\shardingsphere-sql-parser-sql92-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-engine\4.1.1\shardingsphere-sql-parser-engine-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-spi\4.1.1\shardingsphere-sql-parser-spi-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-statement\4.1.1\shardingsphere-sql-parser-statement-4.1.1.jar;D:\mvnrepository\org\apache\commons\commons-collections4\4.2\commons-collections4-4.2.jar;D:\mvnrepository\org\antlr\antlr4-runtime\4.7.2\antlr4-runtime-4.7.2.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-mysql\4.1.1\shardingsphere-sql-parser-mysql-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-postgresql\4.1.1\shardingsphere-sql-parser-postgresql-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-oracle\4.1.1\shardingsphere-sql-parser-oracle-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shardingsphere-sql-parser-sqlserver\4.1.1\shardingsphere-sql-parser-sqlserver-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-route\4.1.1\sharding-core-route-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\master-slave-core-route\4.1.1\master-slave-core-route-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-rewrite\4.1.1\sharding-core-rewrite-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\encrypt-core-rewrite\4.1.1\encrypt-core-rewrite-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\shadow-core-rewrite\4.1.1\shadow-core-rewrite-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-execute\4.1.1\sharding-core-execute-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\sharding-core-merge\4.1.1\sharding-core-merge-4.1.1.jar;D:\mvnrepository\org\apache\shardingsphere\encrypt-core-merge\4.1.1\encrypt-core-merge-4.1.1.jar;D:\mvnrepository\com\google\guava\guava\18.0\guava-18.0.jar;D:\mvnrepository\org\slf4j\slf4j-api\1.7.7\slf4j-api-1.7.7.jar;D:\mvnrepository\org\slf4j\jcl-over-slf4j\1.7.7\jcl-over-slf4j-1.7.7.jar;D:\mvnrepository\junit\junit\4.12\junit-4.12.jar;D:\mvnrepository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 dss.nq.db.ShardingTest,testPartitionKeySelect
Connected to the target VM, address: '127.0.0.1:64216', transport: 'socket'
11:51:56.716 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class dss.nq.db.ShardingTest]
11:51:56.731 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
11:51:56.762 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
11:51:56.900 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [dss.nq.db.ShardingTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
11:51:56.984 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [dss.nq.db.ShardingTest], using SpringBootContextLoader
11:51:56.998 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [dss.nq.db.ShardingTest]: class path resource [dss/nq/db/ShardingTest-context.xml] does not exist
11:51:56.999 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [dss.nq.db.ShardingTest]: class path resource [dss/nq/db/ShardingTestContext.groovy] does not exist
11:51:57.000 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [dss.nq.db.ShardingTest]: no resource found for suffixes {-context.xml, Context.groovy}.
11:51:57.199 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [dss.nq.db.ShardingTest]
11:51:57.692 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [dss.nq.db.ShardingTest]: using defaults.
11:51:57.694 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
11:51:57.745 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@6f8e8894, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@3cfdd820, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@928763c, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@e25951c, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@15f47664, org.springframework.test.context.support.DirtiesContextTestExecutionListener@471a9022, org.springframework.test.context.transaction.TransactionalTestExecutionListener@dc9876b, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@2f666ebb, org.springframework.test.context.event.EventPublishingTestExecutionListener@19976a65, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@a1f72f5, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@4b2c5e02, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@57a3e26a, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@75c56eb9, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@4bc222e, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@2dc9b0f5]
11:51:57.751 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [dss.nq.db.ShardingTest]
11:51:57.755 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [dss.nq.db.ShardingTest]
11:51:57.784 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [dss.nq.db.ShardingTest]
11:51:57.785 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [dss.nq.db.ShardingTest]
11:51:57.789 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [dss.nq.db.ShardingTest]
11:51:57.789 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [dss.nq.db.ShardingTest]
11:51:57.793 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [dss.nq.db.ShardingTest]
11:51:57.793 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [dss.nq.db.ShardingTest]
11:51:57.805 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@7354b8c5 testClass = ShardingTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@20d7d6fb testClass = ShardingTest, locations = '{}', classes = '{class com.dss.sharding.Application}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@fbd1f6, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@7a8c8dcf, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@43c1b556, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@305b7c14, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@26b3fd41, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@402bba4f], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
11:51:57.809 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [dss.nq.db.ShardingTest]
11:51:57.810 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [dss.nq.db.ShardingTest]
11:51:57.927 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.5)
2024-11-14 11:51:59.159 INFO 16500 --- [ main] dss.nq.db.ShardingTest : Starting ShardingTest using Java 1.8.0_152 on DESKTOP-55SE7QS with PID 16500 (started by 92340 in D:\msb\sharding)
2024-11-14 11:51:59.174 INFO 16500 --- [ main] dss.nq.db.ShardingTest : No active profile set, falling back to default profiles: default
2024-11-14 11:52:01.965 INFO 16500 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'stringToNoneShardingStrategyConfigurationConverter' of type [org.apache.shardingsphere.spring.boot.converter.StringToNoneShardingStrategyConfigurationConverter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-14 11:52:02.117 INFO 16500 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.shardingsphere.sharding-org.apache.shardingsphere.shardingjdbc.spring.boot.sharding.SpringBootShardingRuleConfigurationProperties' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.sharding.SpringBootShardingRuleConfigurationProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-14 11:52:02.131 INFO 16500 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.shardingsphere.masterslave-org.apache.shardingsphere.shardingjdbc.spring.boot.masterslave.SpringBootMasterSlaveRuleConfigurationProperties' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.masterslave.SpringBootMasterSlaveRuleConfigurationProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-14 11:52:02.142 INFO 16500 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.shardingsphere.encrypt-org.apache.shardingsphere.shardingjdbc.spring.boot.encrypt.SpringBootEncryptRuleConfigurationProperties' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.encrypt.SpringBootEncryptRuleConfigurationProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-14 11:52:02.188 INFO 16500 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.shardingsphere.shadow-org.apache.shardingsphere.shardingjdbc.spring.boot.shadow.SpringBootShadowRuleConfigurationProperties' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.shadow.SpringBootShadowRuleConfigurationProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-14 11:52:02.201 INFO 16500 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.shardingsphere-org.apache.shardingsphere.shardingjdbc.spring.boot.common.SpringBootPropertiesConfigurationProperties' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.common.SpringBootPropertiesConfigurationProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-14 11:52:03.065 INFO 16500 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration' of type [org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration$$EnhancerBySpringCGLIB$$c6b98db7] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-11-14 11:52:06.709 INFO 16500 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2024-11-14 11:52:07.394 INFO 16500 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2024-11-14 11:52:07.436 INFO 16500 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Starting...
2024-11-14 11:52:07.470 INFO 16500 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Start completed.
2024-11-14 11:52:07.873 INFO 16500 --- [ main] o.a.s.core.log.ConfigurationLogger : ShardingRuleConfiguration:
bindingTables:
- product_order,product_order_item
broadcastTables:
- ad_config
defaultDatabaseStrategy:
inline:
algorithmExpression: ds$->{user_id % 2 }
shardingColumn: user_id
tables:
product_order:
actualDataNodes: ds$->{0..1}.product_order_$->{0..1}
databaseStrategy:
inline:
algorithmExpression: ds$->{user_id % 2 }
shardingColumn: user_id
keyGenerator:
column: id
props:
worker.id: '1'
type: SNOWFLAKE
logicTable: product_order
tableStrategy:
inline:
algorithmExpression: product_order_$->{id % 2}
shardingColumn: id
ad_config:
keyGenerator:
column: id
type: SNOWFLAKE
logicTable: ad_config
product_order_item:
actualDataNodes: ds$->{0..1}.product_order_item_$->{0..1}
logicTable: product_order_item
tableStrategy:
inline:
algorithmExpression: product_order_item_$->{product_order_id % 2}
shardingColumn: product_order_id
2024-11-14 11:52:07.875 INFO 16500 --- [ main] o.a.s.core.log.ConfigurationLogger : Properties:
sql.show: 'true'
2024-11-14 11:52:07.946 INFO 16500 --- [ main] ShardingSphere-metadata : Loading 3 logic tables' meta data.
2024-11-14 11:52:08.104 INFO 16500 --- [ main] ShardingSphere-metadata : Meta data load finished, cost 229 milliseconds.
_ _ |_ _ _|_. ___ _ | _
| | |\/|_)(_| | |_\ |_)||_|_\
/ |
3.4.0
2024-11-14 11:52:11.492 INFO 16500 --- [ main] dss.nq.db.ShardingTest : Started ShardingTest in 13.532 seconds (JVM running for 17.896)
2024-11-14 11:52:14.681 INFO 16500 --- [ main] ShardingSphere-SQL : Logic SQL: SELECT id,out_trade_no,state,create_time,pay_amount,nickname,user_id FROM product_order
WHERE (id = ?)
2024-11-14 11:52:14.681 INFO 16500 --- [ main] ShardingSphere-SQL : SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@2a0ce342, tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@22846a1d), tablesContext=org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext@22846a1d, projectionsContext=ProjectionsContext(startIndex=8, stopIndex=68, distinctRow=false, projections=[ColumnProjection(owner=null, name=id, alias=Optional.empty), ColumnProjection(owner=null, name=out_trade_no, alias=Optional.empty), ColumnProjection(owner=null, name=state, alias=Optional.empty), ColumnProjection(owner=null, name=create_time, alias=Optional.empty), ColumnProjection(owner=null, name=pay_amount, alias=Optional.empty), ColumnProjection(owner=null, name=nickname, alias=Optional.empty), ColumnProjection(owner=null, name=user_id, alias=Optional.empty)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@fe38c0e, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@6167c42f, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@2cbc2db2, containsSubquery=false)
2024-11-14 11:52:14.682 INFO 16500 --- [ main] ShardingSphere-SQL : Actual SQL: ds0 ::: SELECT id,out_trade_no,state,create_time,pay_amount,nickname,user_id FROM product_order_0
WHERE (id = ?) ::: [1856174867678306306]
2024-11-14 11:52:14.683 INFO 16500 --- [ main] ShardingSphere-SQL : Actual SQL: ds1 ::: SELECT id,out_trade_no,state,create_time,pay_amount,nickname,user_id FROM product_order_0
WHERE (id = ?) ::: [1856174867678306306]
2024-11-14 11:52:14.856 INFO 16500 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2024-11-14 11:52:14.892 INFO 16500 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2024-11-14 11:52:14.893 INFO 16500 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown initiated...
2024-11-14 11:52:14.915 INFO 16500 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown completed.
Disconnected from the target VM, address: '127.0.0.1:64216', transport: 'socket'
Process finished with exit code 0