SpringBoot数据库配置文件

1、日常配置

  datasource:
    driver-class-name: org.postgresql.Driver
    url: jdbc:postgresql://192.168.2.142:5432/dev?serverTimezone=UTC&characterEncoding=utf-8&stringtype=unspecified
    username: postgres
    password: 123456
    # 连接池
    hikari:
      #连接池名
      pool-name: DateHikariCP
      #最小空闲连接数
      minimum-idle: 5
      # 空闲连接存活最大时间,默认600000(10分钟)
      idle-timeout: 180000
      # 连接池最大连接数,默认是10
      maximum-pool-size: 100
      # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
      auto-commit: true
      # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
      max-lifetime: 1800000
      # 数据库连接超时时间,默认30秒,即30000
      connection-timeout: 50000
      connection-test-query: SELECT 1

2、shading-jdbc5.0.0配置

spring:
  sharding-sphere:
    datasource:
      names: master
      master:
        type: com.alibaba.druid.pool.DruidDataSource
        driverClassName: org.postgresql.Driver
        url: jdbc:postgresql://127.0.0.1:5432/dev?serverTimezone=UTC&characterEncoding=utf-8&stringtype=unspecified
        username: postgres
        password: 123456
        minimum-idle: 5
        idle-timeout: 180000
        maximum-pool-size: 100
        auto-commit: true
        max-lifetime: 1800000
        connection-timeout: 50000
        connection-test-query: SELECT 1
    rules:
      sharding:
        sharding-algorithms:
          month-sharding-algorithm:
            props:
              strategy: standard
              algorithmClassName: com.base.shading.CreateTimeShardingAlgorithm
            type: CLASS_BASED
        tables:
          unisic_work_procedure:
            actual-data-nodes: master.work_procedure_${2023..2024}_0${1..9},master.work_procedure_${2023..2024}_${10..12}
            table-strategy:
              standard:
                sharding-column: create_time
                sharding-algorithm-name: month-sharding-algorithm
          unisic_work_result:
            actual-data-nodes: master.work_result_${2023..2024}_0${1..9},master.work_result_${2023..2024}_${10..12}
            table-strategy:
              standard:
                sharding-column: create_time
                sharding-algorithm-name: month-sharding-algorithm
        bindingTables:
          - work_procedure, work_result
    props:
      sql-show: false

你可能感兴趣的:(java,数据库,spring,boot,sql)