lolkt commented on issue #37767:
URL: 
https://github.com/apache/shardingsphere/issues/37767#issuecomment-3772019591

       rules:
         readwriteSplitting:
           dataSources:
             readwrite_ds:
               writeDataSourceName: ds-master
               readDataSourceNames:
                 - ds-slave0
                 - ds-slave1
               loadBalancerName: round_robin
           loadBalancers:
             round_robin:
               type: ROUND_ROBIN
           # IMPORTANT: Add single table rule to route all non-sharded tables
         single:
           tables:
             - readwrite_ds.*
           defaultDataSource: readwrite_ds
       props:
         sql-show: true
         check-table-metadata-enabled: false
   
   
   
     @SuppressWarnings("unchecked")
       private SingleRuleConfiguration 
createSingleRuleConfiguration(Map<String, Object> singleConfig) {
           SingleRuleConfiguration result = new SingleRuleConfiguration();
           
           // 设置默认数据源
           if (singleConfig.containsKey("defaultDataSource")) {
               result.setDefaultDataSource((String) 
singleConfig.get("defaultDataSource"));
           }
   
           // 处理表配置:兼容 List 和 Map 两种格式
           if (singleConfig.containsKey("tables")) {
               Object tablesObj = singleConfig.get("tables");
               List<String> tables = new ArrayList<>();
   
               // 情况1:是 List 类型(正常配置)
               if (tablesObj instanceof List) {
                   tables = (List<String>) tablesObj;
               }
               // 情况2:是 Map 类型(YAML 解析异常导致)
               else if (tablesObj instanceof Map) {
                   Map<String, String> tableMap = (Map<String, String>) 
tablesObj;
                   // 提取 Map 的所有 value(通常是通配符 "*")
                   tables.addAll(tableMap.values());
                   log.warn("SingleRule 'tables' was parsed as Map (YAML format 
issue), converted to List: {}", tables);
               }
   
               // 注入解析后的表列表
               if (!tables.isEmpty()) {
                   result.getTables().addAll(tables);
               }
   
           }
           log.info("Created SingleRuleConfiguration with defaultDataSource: 
{}, tables: {}",
                   result.getDefaultDataSource(), result.getTables());
           return result;
       }
   
   
   
   @terrymanu  The issue has been fixed after adding the single configuration. 
Thank you very much!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to