关键配置如下:
<rdb:data-source id="shardingDataSource">
<rdb:sharding-rule data-sources="dataSourcejdbc" default-data-source="dataSourcejdbc">
<rdb:table-rules>
<rdb:table-rule logic-table="t_call_detail" dynamic="true" table-strategy="tableStrategy"/>
</rdb:table-rules>
<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>
报错信息如下:
Caused by: java.lang.IllegalStateException: Missing the rule of information_schema in DataSourceRule
at com.google.common.base.Preconditions.checkState(Preconditions.java:200)
at com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection.getConnectionInternal(ShardingConnection.java:101)
at com.dangdang.ddframe.rdb.sharding.jdbc.ShardingConnection.getConnection(ShardingConnection.java:64)
at com.dangdang.ddframe.rdb.sharding.jdbc.ShardingPreparedStatement.routeSQL(ShardingPreparedStatement.java:167)
at com.dangdang.ddframe.rdb.sharding.jdbc.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:115)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:59)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:73)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:60)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
at com.ffzx.commerce.framework.interceptor.PaginationInterceptor.intercept(PaginationInterceptor.java:84)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:60)
at com.sun.proxy.$Proxy43.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
... 53 more
如果不用分库分表,请不要使用sharing-jdbc,而是用spring等管理不同的数据源。把分库分表的数据源和不分的分离开
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。