ShardingSphere-JDBC异常: no table route info

错误代码:Cause: java.lang.IllegalStateException: no table route info

### The error may involve com.huohuo.sharding.mapper.CourseMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO course  ( id, name, type, status )  VALUES  ( ?, ?, ?, ? )
### Cause: java.lang.IllegalStateException: no table route info

在这里插入图片描述
我们看日志记录可以看到JDBC配置tables如下:

tables:
  course:
    actualDataNodes: m1.course_$->{1..2}
    keyGenerator:
      column: id
      props:
        worker.id: '1'
      type: SNOWFLAKE
    logicTable: course
    tableStrategy:
      inline:
        algorithmExpression: m1.course_$->{status.toInteger()%2+1}
        shardingColumn: status
  user:
    actualDataNodes: m1.user_$->{1..2}
    keyGenerator:
      column: id
      props:
        worker.id: '1'
      type: SNOWFLAKE
    logicTable: user
    tableStrategy:
      inline:
        algorithmExpression: m1.user_$->{status.toInteger()%2+1}
        shardingColumn: status

到底哪里出了问题???看配置文件配置,找了半天不晓得哪里的问题,最终也只是把algorithm-expression的value改动了一下,之前是m1. 然后把这个去掉就执行成功了。

#actual-data-nodes course这个逻辑表对应的真实的表分布 m1.course_1 m1.course_2
spring.shardingsphere.sharding.tables.course.actual-data-nodes=m1.course_$->{1..2}
#主键生成策略 对cid进行一下生成,采用了雪花算法 SNOWFLAKE;对worker.id可不配置,有默认值
spring.shardingsphere.sharding.tables.course.key-generator.column=id
spring.shardingsphere.sharding.tables.course.key-generator.type=SNOWFLAKE
spring.shardingsphere.sharding.tables.course.key-generator.props.worker.id=1
spring.shardingsphere.sharding.tables.course.table-strategy.inline.sharding-column=status
spring.shardingsphere.sharding.tables.course.table-strategy.inline.algorithm-expression=course_$->{status.toInteger()%2+1}


spring.shardingsphere.sharding.tables.user.actual-data-nodes=m1.user_$->{1..2}
spring.shardingsphere.sharding.tables.user.key-generator.column=id
spring.shardingsphere.sharding.tables.user.key-generator.type=SNOWFLAKE
spring.shardingsphere.sharding.tables.user.key-generator.props.worker.id=1
spring.shardingsphere.sharding.tables.user.table-strategy.inline.sharding-column=status
spring.shardingsphere.sharding.tables.user.table-strategy.inline.algorithm-expression=user_$->{status.toInteger()%2+1}

error报错就是:没有表路由信息,不知道锁定那张表,但是就是一个库m1,为何加上m1就不行呢?
目前觉得因为是分表配置,无需加上相关变动value,当执行分库策略时候,就不得不加上前缀了。

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值