shardingsphere springboot application.yml配置

shardingsphere  springboot application.yml配置

 

spring:
  sharding-sphere:
    datasource:
      names: master
      master:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class-name: com.mysql.cj.jdbc.Driver
        jdbc-url: jdbc:mysql://xxx.xxx.xxx.xxx:3306/databse?useSSL=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&rewriteBatchedStatements=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
        username: test
        password: test@1024
        maximum-pool-size: 50 # 最大連接池數
        max-lifetime: 180000 # 連接的最長生週期,值0表示無限生命週期,默認1800000即30分鐘
        minimum-idle: 5 # 最小空閒連接數量
        idle-timeout: 180000 # 空閒連接存活最大時間,默認600000 (10分鐘)
        connection-timeout: 60000 #連接超時時間
        validation-timeout: 3000 #制連接測試活動的最長時間
        connection-test-query: select 1
      sharding:
        default-data-source-name: master
      tables:
        tbl_file_info:
          actual-data-nodes: master.tbl_file_info_$->{2023..2024}$->{(1..12).collect{t->t.toString().padLeft(2,'0')}},master.tbl_file_info_$->{2022}$->{(10..12).collect{t->t.toString().padLeft(2,'0')}}
          table-strategy:
            standard:
              sharding-column: create_time
              precise-aLorthn-cLass-name: xxx.xxx.TablePreciseShardingalgrithn #自定義分表,插入 或帶create_time的精確查飾用
              range-algorithm-class-name: xxx.xxx.TablePreciseShardingAlgorithm #範圍查詢
      props:
        sql:
          show: true #打印sql
        executor:
          size: 10#工作線程數量,默認值: CPU核數
        allow:
          range:
            query:
              with:
                inline:
                sharding:true '#當使用inline分表策略時,是否允連範圍查詢,默認值:false

 

shardingDataSourceFactory  可以打斷點查看配置

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章