stephensuxun opened a new issue #11293:
URL: https://github.com/apache/shardingsphere/issues/11293


   使用sharding JDBC 版本4.1.1 
   <dependency>
               <groupId>com.baomidou</groupId>
               <artifactId>mybatis-plus-boot-starter</artifactId>
               <version>3.4.1</version>
     </dependency>
           <!--依赖sharding-jdbc start-->
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
               <version>4.1.1</version>
           </dependency>
   
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-spring-namespace</artifactId>
               <version>4.1.1</version>
           </dependency>
   
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-core-common</artifactId>
               <version>4.1.1</version>
           </dependency>
   
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-jdbc</artifactId>
               <version>2.5.2</version>
           </dependency>
   <!--依赖sharding-jdbc end -->
   
   分表配置
   # 配置默认数据源
   # 命名数据源  这个是自定义的
   spring.shardingsphere.datasource.names=ds-0,ds-1
   # 配置默认数据源ds-0
   spring.shardingsphere.sharding.default-data-source-name=ds-0
   
   # ds-0数据源
   
spring.shardingsphere.datasource.ds-0.type=com.alibaba.druid.pool.DruidDataSource
   
spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.cj.jdbc.Driver
   
spring.shardingsphere.datasource.ds-0.url=jdbc:mysql://172.16.20.3:3306/ainewssystem-cloud?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
   spring.shardingsphere.datasource.ds-0.username=***
   spring.shardingsphere.datasource.ds-0.password=***
   
   # ds-1数据源
   
spring.shardingsphere.datasource.ds-1.type=com.alibaba.druid.pool.DruidDataSource
   
spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.cj.jdbc.Driver
   
spring.shardingsphere.datasource.ds-1.url=jdbc:mysql://172.16.20.3:3306/ainewssystem-cloud?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
   spring.shardingsphere.datasource.ds-1.username=***
   spring.shardingsphere.datasource.ds-1.password=***
   
   
   # 配置分片表 ainews_user
   # 配置真实数据节点  库:ds-0,ds-1;表:ainews_user_0,ainews_user_1
   
spring.shardingsphere.sharding.tables.ainews_user.actual-data-nodes=ds-$->{0..1}.ainews_user_$->{0..1}
   # 分表分片
   
spring.shardingsphere.sharding.tables.ainews_user.table-strategy.inline.sharding-column=user_id
   
spring.shardingsphere.sharding.tables.ainews_user.table-strategy.inline.algorithm-expression=ainews_user_->{user_id
 % 2}
   # 配置自增主键字段
   
spring.shardingsphere.sharding.tables.ainews_user.key-generator.column=user_id
   # 自增主键ID 生成方案:雪花算法
   
spring.shardingsphere.sharding.tables.ainews_user.key-generator.type=SNOWFLAKE
   
   ##查看sql的输出日志
   spring.shardingsphere.props.sql.show=true
   ##一个实体类对应两张表的设置
   spring.main.allow-bean-definition-overriding = true
   
   创建ainews_user_0表
   CREATE TABLE `ainews_user_0`  (
     `user_id` bigint(20) NOT NULL COMMENT '用户ID',
     `user_account` varchar(100) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户账号',
     `user_name` varchar(100) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户名',
     `nick_name` varchar(100) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户昵称',
     `user_password` varchar(255) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户密码',
     `user_header_portrait` varchar(255) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户的头像',
     `user_email` varchar(100) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户的邮箱地址',
     `user_used_amount` int(11) NULL DEFAULT 0 COMMENT '用户使用的数量',
     `user_total_usage` int(20) NULL DEFAULT 0 COMMENT '用户使用的总量',
     `user_salt` varchar(20) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户的盐值',
     `user_secret` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci 
NULL COMMENT '用户的密文',
     `user_status` int(2) NULL DEFAULT 1 COMMENT '用户的状态 0代表冻结 1代表正常',
     `user_type` varchar(10) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT '0' COMMENT '用户的类型 -1测试 0普通用户 1付费用户 2普通企业 
3付费企业',
     `is_authentication` varchar(10) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT '-1' COMMENT '是否通过认证 -1未认证 1个人认证 2企业认证 
3代表审核中',
     `user_grade` int(11) NULL DEFAULT 1 COMMENT '用户的等级',
     `user_point` varchar(32) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT '0' COMMENT '用户的积分',
     `user_create_amount` int(11) NULL DEFAULT 0 COMMENT '用户创作的数量',
     `user_collect_amount` int(11) NULL DEFAULT 0 COMMENT '用户收藏的数量',
     `expiration_date` datetime(0) NULL DEFAULT NULL COMMENT '到期时间',
     `create_time` datetime(0) NULL DEFAULT NULL COMMENT '用户注册时间',
     `update_time` datetime(0) NULL DEFAULT NULL COMMENT '用户更新时间',
     `version` int(11) NULL DEFAULT 0 COMMENT '乐观锁',
     `deleted` int(2) NULL DEFAULT 0 COMMENT '逻辑删除',
     `token` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NULL 
COMMENT '用户的token',
     PRIMARY KEY (`user_id`) USING BTREE
   ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_520_ci 
COMMENT = '人工智能语音平台用户表' ROW_FORMAT = Dynamic;
   
   创建ainews_user_1表
   CREATE TABLE `ainews_user_1`  (
     `user_id` bigint(20) NOT NULL COMMENT '用户ID',
     `user_account` varchar(100) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户账号',
     `user_name` varchar(100) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户名',
     `nick_name` varchar(100) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户昵称',
     `user_password` varchar(255) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户密码',
     `user_header_portrait` varchar(255) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户的头像',
     `user_email` varchar(100) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户的邮箱地址',
     `user_used_amount` int(11) NULL DEFAULT 0 COMMENT '用户使用的数量',
     `user_total_usage` int(20) NULL DEFAULT 0 COMMENT '用户使用的总量',
     `user_salt` varchar(20) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT NULL COMMENT '用户的盐值',
     `user_secret` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci 
NULL COMMENT '用户的密文',
     `user_status` int(2) NULL DEFAULT 1 COMMENT '用户的状态 0代表冻结 1代表正常',
     `user_type` varchar(10) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT '0' COMMENT '用户的类型 -1测试 0普通用户 1付费用户 2普通企业 
3付费企业',
     `is_authentication` varchar(10) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT '-1' COMMENT '是否通过认证 -1未认证 1个人认证 2企业认证 
3代表审核中',
     `user_grade` int(11) NULL DEFAULT 1 COMMENT '用户的等级',
     `user_point` varchar(32) CHARACTER SET utf8mb4 COLLATE 
utf8mb4_unicode_520_ci NULL DEFAULT '0' COMMENT '用户的积分',
     `user_create_amount` int(11) NULL DEFAULT 0 COMMENT '用户创作的数量',
     `user_collect_amount` int(11) NULL DEFAULT 0 COMMENT '用户收藏的数量',
     `expiration_date` datetime(0) NULL DEFAULT NULL COMMENT '到期时间',
     `create_time` datetime(0) NULL DEFAULT NULL COMMENT '用户注册时间',
     `update_time` datetime(0) NULL DEFAULT NULL COMMENT '用户更新时间',
     `version` int(11) NULL DEFAULT 0 COMMENT '乐观锁',
     `deleted` int(2) NULL DEFAULT 0 COMMENT '逻辑删除',
     `token` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NULL 
COMMENT '用户的token',
     PRIMARY KEY (`user_id`) USING BTREE
   ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_520_ci 
COMMENT = '人工智能语音平台用户表' ROW_FORMAT = Dynamic;
   
   提交的参数
   
   {
     "userAccount": "13186038211",
     "userName": "kevin",
     "userPassword": 
"8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92",
     "verificationCode": "123456"
   }
   
   报错
   2021-07-12 19:47:09.712  WARN 1823 --- [nio-7091-exec-1] 
.m.m.a.ExceptionHandlerExceptionResolver : Resolved 
[org.mybatis.spring.MyBatisSystemException: nested exception is 
org.apache.ibatis.exceptions.PersistenceException: 
   ### Error updating database.  Cause: java.lang.IllegalStateException: no 
table route info
   ### The error may exist in 
com/ainewssystem/cloud/user/core/user/mapper/AiNewsUserMapper.java (best guess)
   ### The error may involve 
com.ainewssystem.cloud.user.core.user.mapper.AiNewsUserMapper.insert-Inline
   ### The error occurred while setting parameters
   ### SQL: INSERT INTO ainews_user  ( user_id, user_account, user_name, 
nick_name, user_password,   user_used_amount,           expiration_date, 
create_time, update_time )  VALUES  ( ?, ?, ?, ?, ?,   ?,           ?, ?, ? )
   ### Cause: java.lang.IllegalStateException: no table route info]
   是否与mybatis plus兼容


-- 
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]


Reply via email to