harmonyzhang opened a new issue, #34724:
URL: https://github.com/apache/shardingsphere/issues/34724

   @Bean(name = DEFAULT_DATASOURCE)
   public DataSource defaultDataSource() throws SQLException {
       ReadwriteSplittingDataSourceGroupRuleConfiguration dataSourceConfig = 
new ReadwriteSplittingDataSourceGroupRuleConfiguration("ds_0", "ds_0_0", 
Arrays.asList("ds_0_1", "ds_0_2"), "round_lb");
       ReadwriteSplittingDataSourceGroupRuleConfiguration dataSourceConfig1 = 
new ReadwriteSplittingDataSourceGroupRuleConfiguration("ds_1", "ds_1_0", 
Arrays.asList("ds_1_1", "ds_1_2"), "round_lb");
       // 使用轮询负载均衡算法         
       Map<String, AlgorithmConfiguration> algorithmConfigMap = new 
HashMap<>(1);
       algorithmConfigMap.put("round_lb", new 
AlgorithmConfiguration("ROUND_ROBIN", new Properties()));
       ReadwriteSplittingRuleConfiguration ruleConfig = new 
ReadwriteSplittingRuleConfiguration(Arrays.asList(dataSourceConfig, 
dataSourceConfig1), algorithmConfigMap);
       Properties props = new Properties();
       props.setProperty("sql-show", Boolean.TRUE.toString());
       Map<String, DataSource> dataSourceMap = createDataSourceMap();
       
       return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, 
Arrays.asList(ruleConfig, createShardingRuleConfiguration()), props);
   }
   
   // 分片配置     
   private ShardingRuleConfiguration createShardingRuleConfiguration() throws 
SQLException {
       ShardingRuleConfiguration result = new ShardingRuleConfiguration();
       result.getTables().add(getTableRuleConfiguration("t_order"));
       result.setDefaultDatabaseShardingStrategy(new 
StandardShardingStrategyConfiguration("company_id", "geo-hash-algorithm"));
       result.setDefaultTableShardingStrategy(new 
StandardShardingStrategyConfiguration("company_id", 
"table-customize-algorithm"));
       Properties props = new Properties();
       props.setProperty("strategy", "standard");
       // 标准算法         
       props.setProperty("algorithmClassName", 
GeoHashShardingAlgorithm.class.getName());
       result.getShardingAlgorithms().put("geo-hash-algorithm", new 
AlgorithmConfiguration("CLASS_BASED", props));
       Properties props1 = new Properties();
       props1.setProperty("strategy", "standard");
       // 标准算法         
       props1.setProperty("algorithmClassName", 
TableCustomizeShardingAlgorithm.class.getName());
       result.getShardingAlgorithms().put("table-customize-algorithm", new 
AlgorithmConfiguration("CLASS_BASED", props1));
       return result;
   }
   
   private ShardingTableRuleConfiguration getTableRuleConfiguration(String 
tableName) {
       ShardingTableRuleConfiguration result = new 
ShardingTableRuleConfiguration(tableName, "ds_${0..1}." + tableName);
       return result;
   }
   
   private Map<String, DataSource> createDataSourceMap() {
       Map<String, DataSource> result = new HashMap<>(6, 1);
       result.put("ds_0_0", createDataSource(readwriteProperties()));
       result.put("ds_0_1", createDataSource(read1Properties()));
       result.put("ds_0_2", createDataSource(read2Properties()));
       result.put("ds_1_0", createDataSource(readwriteProperties()));
       result.put("ds_1_1", createDataSource(read1Properties()));
       result.put("ds_1_2", createDataSource(read2Properties()));
       return result;
   }
   
   version: 5.5.1
   
   Using the above configuration, the business error indicates that the table 
does not exist. It is found that tables without configured rules are all 
unavailable, and neither the custom database sharding algorithm nor the table 
sharding algorithm has been executed.
   
   


-- 
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: 
notifications-unsubscr...@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to