集成 shardingsphere-jdbc 常见问题

一、报错内容

Caused by: org.apache.ibatis.executor.ExecutorException: Error preparing statement.  Cause: org.apache.shardingsphere.infra.exception.kernel.metadata.TableNotFoundException: Table or view 't_xxx' does not exist.

解决

1、配置 !SHARDING

rules:
  - !SHARDING
    tables:
      #逻辑表名称(一般取表前缀),逻辑表和实际表映射
      t:
        actualDataNodes: ds_${0..1}.t_${0..1}

说明:
【1】t:是逻辑表名称(一般取表前缀),逻辑表和实际表映射
【2】actualDataNodes:把逻辑表映射到实际表命名规则。语法:数据源逻辑名_序号索引值.逻辑表名称_序号索引值,示例:ds_${0..1}.t_${0..1}

2、配置 !SINGLE

rules:
  - !SINGLE
    defaultDataSource: ds_0
    tables:
	  # 加载全部数据源的全部单表
   

你可能感兴趣的:(SpringBoot,MySQL,Oracle,PostgreSQL,spring,boot,mysql)