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

   # 数据源
   spring:
     # shardingsphere配置
     shardingsphere:
       # 打印sql
       props:
         #打印sql
         sql-show: true
       # 数据源
       datasource:
         #默认数据源别名
         #default-data-source-name: ds1
         # 名称
         names: ds1,ds2
         # 数据源1
         ds1:
           # type在boot里是默认配置,但在shardingsphere里必须手动配置
           type: com.zaxxer.hikari.HikariDataSource
           # 物理数据库配置1
           driver-class-name: com.mysql.cj.jdbc.Driver
           jdbc-url: 
jdbc:mysql://localhost:3306/demo1?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
           username: root
           password: 111111
         # 数据源2
         ds2:
           # type在boot里是默认配置,但在shardingsphere里必须手动配置
           type: com.zaxxer.hikari.HikariDataSource
           # 物理数据库配置2
           driver-class-name: com.mysql.cj.jdbc.Driver
           jdbc-url: 
jdbc:mysql://localhost:3306/demo2?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
           username: root
           password: 111111
       rules:
         sharding:
           default-database-strategy:
             HINT:
               shardingAlgorithmName: my_data_hint
           # 分片算法定义
           sharding-algorithms:
             # 自定义 hint 标准算法
             my_data_hint:
               type: CLASS_BASED
               props:
                 # 分片策略
                 strategy: hint
                 # 分片算法类
                 algorithmClassName: 
com.coco.sharding.config.MyDatasourceRoutingAlgorithm
           tables:
             # 逻辑表名称 test
             test:
               # 数据节点:数据库.分片表
               actual-data-nodes: ds$->{1..2}.test
               
   现在有2个数据库,ds1, ds2,在业务场景方法中我想随意的切换使用哪个库哪个表,我想使用自定义的策略,
   例如
   方法{
   save ds1.table1
   save ds2.table2
   }
   但是程序走不到自定义的策略
   default-database-strategy:
             HINT:
               shardingAlgorithmName: my_data_hint
   这个配置哪里有问题吗
           


-- 
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