作者:Eddy  历史版本:1  最后编辑:龚清  更新时间:2024-11-20 15:41

编写版本:v3.5.5
适用版本:v3.5.5+

如何使用yml配置数据源

  1. 在ibps-basic-response工程application-common.yml中配置com.lc.db.datasources.xml.enabled: ${DATASOURCES_XML_ENABLED:false}
  2. 在ibps-basic-response工程application-common.yml中配置com.lc.db.datasources.yml.enabled: ${DATASOURCES_YML_ENABLED:true}
  3. 设置数据库连接池类型
    • druid,在ibps-basic-response工程application-common.yml中配置com.lc.db.datasources.druid-enabled: ${DATASOURCES_DRUID_ENABLED:true}com.lc.db.datasources.hikari-enabled: ${DATASOURCES_HIKARI_ENABLED:false}
    • hikari,在ibps-basic-response工程application-common.yml中配置com.lc.db.datasources.druid-enabled: ${DATASOURCES_DRUID_ENABLED:false}com.lc.db.datasources.hikari-enabled: ${DATASOURCES_HIKARI_ENABLED:true}
  4. 在服务工程的application-app.yml文件中添加数据源配置,以Oauth服务为例
    – application-common.yml
    com:
    lc:
     db:
       datasources:
         druid-enabled: ${DATASOURCES_DRUID_ENABLED:true}
         hikari-enabled: ${DATASOURCES_HIKARI_ENABLED:false}

– application-app.yml

com:
  lc:
    db:
      datasources:
        xml:
          enabled: ${DATASOURCES_XML_ENABLED:true}
        yml:
          enabled: ${DATASOURCES_YML_ENABLED:false}
          druid:
            - name: def
              alias: dataSource_default
              dbType: mysql
              driver: com.mysql.cj.jdbc.Driver
              driverUrl: jdbc:mysql://192.168.3.220:50000/ibps_platform_v3.5.4_optimize?useDynamicCharsetInfo=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=CTT
              user: root
              password: root
              status: actived
              isDefault: true
              variables:
                validationQuery: SELECT 1 FROM IBPS_RIGHTS_CONF
                testWhileIdle: true
                testOnBorrow: false
                testOnReturn: false
                maxPoolPreparedStatementPerConnectionSize: 20
                removeAbandonedTimeout: 1800
                logAbandoned: true
                poolPreparedStatements: true
                maxActive: 64
                minIdle: 10
                initialSize: 5
                removeAbandoned: true
                timeBetweenEvictionRunsMillis: 300000
                minEvictableIdleTimeMillis: 180000
                filters: stat
          hikari:
            - name: def
              alias: dataSource_default
              dbType: mysql
              driver: com.mysql.cj.jdbc.Driver
              driverUrl: jdbc:mysql://192.168.3.220:50000/ibps_platform_v3.5.4_optimize?useDynamicCharsetInfo=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=CTT
              user: root
              password: root
              status: actived
              isDefault: true
              variables:
                connectionTestQuery: Select 1 from
                connectionTimeout: 15000
                maxLifetime: 1800000
                maximumPoolSize: 64
                minimumIdle: 10
                idleTimeout: 500000