ShardingJdbcException: Cannot find table rule and default data source with logic tables: '[]'
问题
1.5.4 sharding-jdbc ,单库 ,有一部分 分表,其余的部分表
<dependency> <groupId>com.dangdang</groupId> <artifactId>sharding-jdbc-core</artifactId> <version>1.5.4</version> </dependency> <dependency> <groupId>com.dangdang</groupId> <artifactId>sharding-jdbc-config-spring</artifactId> <version>1.5.4</version> </dependency> <!--主键生成--> <dependency> <groupId>com.dangdang</groupId> <artifactId>sharding-jdbc-self-id-generator</artifactId> <version>1.4.2</version> </dependency>
<!-- 分表 --> <rdb:strategy id="tableShardingStrategy" sharding-columns="uid" algorithm-class="com.smartwork.msip.business.shard.impl.shardstrategy.AccountRelationTableShardingAlgorithm" /> <rdb:data-source id="shardingDataSourceMaster"> <rdb:sharding-rule data-sources="dataSourceCoreMaster" default-data-source="dataSourceCoreMaster1" > <rdb:table-rules> <rdb:table-rule logic-table="user_relation" actual-tables="user_relation_00,user_relation_01,user_relation_02" table-strategy="tableShardingStrategy"/> <rdb:table-rule logic-table="short_video" actual-tables="short_video_00,short_video_01,short_video_02" table-strategy="tableShardingStrategy"/> </rdb:table-rules> <!-- <rdb:default-table-strategy sharding-columns="uid" algorithm-class="com.smartwork.msip.business.shard.impl.shardstrategy.AccountRelationTableShardingAlgorithm" />--> <!--默认不分表--> <rdb:default-database-strategy sharding-columns="none" algorithm-class="com.dangdang.ddframe.rdb.sharding.api.strategy.database.NoneDatabaseShardingAlgorithm"/> <!-- <rdb:default-table-strategy sharding-columns="none" algorithm-class="com.dangdang.ddframe.rdb.sharding.api.strategy.table.NoneTableShardingAlgorithm"/>--> </rdb:sharding-rule> <rdb:props> <prop key="metrics.enable">false</prop> </rdb:props> </rdb:data-source>
其中在保存不分表的数据的时候 报 如下错误
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error selecting key or setting result to parameter object. Cause: com.dangdang.ddframe.rdb.sharding.exception.ShardingJdbcException: Cannot find table rule and default data source with logic tables: '[]'
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75) ~[mybatis-spring-1.2.2.jar:1.2.2]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371) ~[mybatis-spring-1.2.2.jar:1.2.2]
at com.sun.proxy.$Proxy16.insert(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:240) ~[mybatis-spring-1.2.2.jar:1.2.2]
at com.mtr.toplines.business.account.dao.AccountDao.insert(AccountDao.java:97) ~[msip_mtr_business_ds-1.0.jar:na]
at com.mtr.toplines.business.account.dao.AccountDao.insert(AccountDao.java:18) ~[msip_mtr_business_ds-1.0.jar:na]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
怎么解决的、我也这个问题,但是我主键不是自增的
已解决
是用自增主键 所造成的问题,把这个去掉 ,换成自己生成的唯一主键 即可