1
回答
Cannot find table rule and default data source with logic tables: '[]'
极速云服务器,低至1.04元/天>>>   

报的异常信息如下:

com.dangdang.ddframe.rdb.sharding.exception.ShardingJdbcException: Cannot find table rule and default data source with logic tables: '[]'
        at com.dangdang.ddframe.rdb.sharding.routing.type.complex.ComplexRoutingEngine.route(ComplexRoutingEngine.java:81)
        at com.dangdang.ddframe.rdb.sharding.routing.router.ParsingSQLRouter.route(ParsingSQLRouter.java:123)
        at com.dangdang.ddframe.rdb.sharding.routing.router.ParsingSQLRouter.route(ParsingSQLRouter.java:89)
        at com.dangdang.ddframe.rdb.sharding.routing.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:56)
        at com.dangdang.ddframe.rdb.sharding.jdbc.core.statement.ShardingPreparedStatement.route(ShardingPreparedStatement.java:120)
        at com.dangdang.ddframe.rdb.sharding.jdbc.core.statement.ShardingPreparedStatement.executeQuery(ShardingPreparedStatement.java:84)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
        at org.hibernate.loader.Loader.doQuery(Loader.java:674)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
        at org.hibernate.loader.Loader.doList(Loader.java:2220)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
        at org.hibernate.loader.Loader.list(Loader.java:2099)

配置如下:

<rdb:strategy id="tableStrategy" sharding-columns="TIME" algorithm-class="com.util.parse.TableShardingAlgorithm"/>

<rdb:data-source id="shardingdataSource">
   <rdb:sharding-rule data-sources="ds_01" default-data-source="generalDataSource">
      <rdb:table-rules>
         <rdb:table-rule logic-table="audit_record" dynamic="true" table-strategy="tableStrategy"/>
      </rdb:table-rules>
      <rdb:binding-table-rules>
         <rdb:binding-table-rule logic-tables="audit_record"/>
      </rdb:binding-table-rules>
      <rdb:default-database-strategy sharding-columns="none" algorithm-class="com.dangdang.ddframe.rdb.sharding.api.strategy.database.NoneDatabaseShardingAlgorithm"/>
   </rdb:sharding-rule>
   <rdb:props>
      <prop key="metrics.enable">true</prop>
   </rdb:props>
</rdb:data-source>
举报
liuhuachun
发帖于2个月前 1回/88阅
顶部