zoukankan      html  css  js  c++  java
  • SpringBoot 多数据源配置(未完)

    使用druid数据源

    配置文件

    spring:
      datasource:
        druid:
          msg:
            driver-class-name: com.mysql.cj.jdbc.Driver
            # 如果使用SpringBoot提供的默认数据源HiKari, 那么 spring.datasource.jdbc-url 用来重写自定义连接池,使用HiKari只有jdbcUrl属性
            url: jdbc:mysql://localhost:3306/msg?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&pinGlobalTxToPhysicalConnection=true&autoReconnect=true
            username: root
            password: root
            # 连接池初始化大小
            initial-size: 5
            # 最小连接池数量
            min-idle: 5
            # 最大连接池数量
            max-active: 10
            # 获取连接时,最大等待时间,单位ms,配置了 maxWait 之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置 useUnfairLock 属性为 true 使用非公平锁。
            max-wait: 60000
            # 销毁Destroy,线程会间隔一段时间(单位ms)检测连接的空闲时间,如果大于等于 min-evictable-idle-time-millis,则关闭物理连接
            time-between-eviction-runs-millis: 60000
            # 连接保持空闲而不被驱逐的最小时间
            min-evictable-idle-time-millis: 300000
            # 用来检测连接是否有效的,sql因使用的数据库而异,例如:oracle 应该写成 SELECT 1 FROM DUAL
            validation-query: SELECT 1
            # 是否开启连接检测,如果空闲时间大于 time-between-eviction-runs-millis 则执行 validation-query 检测连接是否有效,建议配置为 true,不影响性能,并且保证安全性
            test-while-idle: true
            # 申请连接时执行 validationQuery 检测连接是否有效,做了这个配置会降低性能。
            test-on-borrow: false
            # 归还连接时执行 validationQuery 检测连接是否有效,做了这个配置会降低性能。
            test-on-return: false
            # 连接使用超过时间限制是否自动回收
            remove-abandoned: true
            # 限制连接使用的最大时间(以秒数为单位)
            remove-abandoned-timeout: 1800
            # 连接回收时,在控制台打印信息,测试环境下加上true,线上环境改为false,影响性能
            log-abandoned: true
            pinGlobalTxToPhysicalConnection: true
          db01:
            driver-class-name: com.mysql.cj.jdbc.Driver
            url: jdbc:mysql://localhost:3306/db01?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&pinGlobalTxToPhysicalConnection=true&autoReconnect=true
            username: root
            password: root
            initialSize: 5
            minIdle: 5
            maxActive: 10
            maxWait: 60000
            timeBetweenEvictionRunsMillis: 60000
            minEvictableIdleTimeMillis: 300000
            validationQuery: SELECT 1
            testWhileIdle: true
            testOnBorrow: false
            testOnReturn: false
            removeAbandoned: true
            remove-abandoned-timeout: 1800
            logAbandoned: true
            pinGlobalTxToPhysicalConnection: true
          db02:
            driver-class-name: com.mysql.cj.jdbc.Driver
            url: jdbc:mysql://localhost:3306/db02?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&pinGlobalTxToPhysicalConnection=true&autoReconnect=true
            username: root
            password: root
            initialSize: 5
            minIdle: 5
            maxActive: 10
            maxWait: 60000
            timeBetweenEvictionRunsMillis: 60000
            minEvictableIdleTimeMillis: 300000
            validationQuery: SELECT 1
            testWhileIdle: true
            testOnBorrow: false
            testOnReturn: false
            removeAbandoned: true
            remove-abandoned-timeout: 1800
            logAbandoned: true
            pinGlobalTxToPhysicalConnection: true
          db03:
            driver-class-name: com.mysql.cj.jdbc.Driver
            url: jdbc:mysql://localhost:3306/db03?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&pinGlobalTxToPhysicalConnection=true&autoReconnect=true
            username: root
            password: root
            initialSize: 5
            minIdle: 5
            maxActive: 10
            maxWait: 60000
            timeBetweenEvictionRunsMillis: 60000
            minEvictableIdleTimeMillis: 300000
            validationQuery: SELECT 1
            testWhileIdle: true
            testOnBorrow: false
            testOnReturn: false
            removeAbandoned: true
            remove-abandoned-timeout: 1800
            logAbandoned: true
            pinGlobalTxToPhysicalConnection: true
          # WebStatFilter 用于采集 web-jdbc 关联监控的数据。
          web-stat-filter:
            # 是否开启 WebStatFilter 默认是 true
            enabled: true
            # 需要拦截的 url
            url-pattern: /*
            # 排除静态资源的请求
            exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
          # Druid 内置提供了一个 StatViewServlet 用于展示 Druid 的统计信息。
          stat-view-servlet:
            #是否启用 StatViewServlet 默认值 true
            enabled: true
            # 需要拦截的 url
            url-pattern: /druid/*
            # 允许清空统计数据
            reset-enable: true
            login-username: admin
            login-password: 123456
    致力于记录学习过程中的笔记,希望大家有所帮助(*^▽^*)!
  • 相关阅读:
    如何给caffe添加新的layer ?
    caffe: test code Check failed: K_ == new_K (768 vs. 1024) Input size incompatible with inner product parameters.
    caffe: test code for PETA dataset
    matlab:对一个向量进行排序,返回每一个数据的rank 序号 。。。
    ant.design初探
    如何在react&webpack中引入图片?
    react&webpack使用css、less && 安装原则 --- 从根本上解决问题。
    如何制作高水平简历?&& 制作简历时需要注意的问题
    npm全局安装和局部文件安装区别
    职业人的基本素养
  • 原文地址:https://www.cnblogs.com/zxhbk/p/13947048.html
Copyright © 2011-2022 走看看