springboot 整合mysql clickhouse 多数据源

最近做一个项目 需要 整合mysql clickhouse 多数据源

后台用的是ruoyi框架

但是不知道作者自己写的datasource config文件是不是有问题 永远不能成功的加载第二个数据源

于是索性把作者写的datasource config全部删除了,然后配置文件用的是老项目的多数据源配置文件

于是就成功了  这个坑踩了2天

management:
    endpoints:
        web:
            exposure:
                include: '*'
spring:
    resources:
        static-locations: classpath:/static/,classpath:/templates/
    mvc:
        throw-exception-if-no-handler-found: true
        static-path-pattern: /**
    application:
        name: merak-light
    main:
        allow-bean-definition-overriding: true
    #json 时间戳统一转换
    jackson:
        date-format:   yyyy-MM-dd HH:mm:ss
        time-zone:   GMT+8
    aop:
        proxy-target-class: true
    autoconfigure:
        exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
    datasource:
        dynamic:
            druid:
                # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
                # 连接池的配置信息
                # 初始化大小,最小,最大
                initial-size: 1
                min-idle: 1
                maxActive: 20
                # 配置获取连接等待超时的时间
                maxWait: 60000
                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
                timeBetweenEvictionRunsMillis: 60000
                # 配置一个连接在池中最小生存的时间,单位是毫秒
                minEvictableIdleTimeMillis: 300000
                validationQuery: SELECT 1
                testWhileIdle: true
                testOnBorrow: false
                testOnReturn: false
                # 打开PSCache,并且指定每个连接上PSCache的大小
                poolPreparedStatements: true
                maxPoolPreparedStatementPerConnectionSize: 20
                # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
                filters: stat,slf4j
                # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
                connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
            datasource:
                master:
                    url: jdbc:mysql://xxxx:3306/light?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                    username: xxx
                    password: xxx
                    driver-class-name: com.mysql.jdbc.Driver
                slave:
                    driver-class-name: ru.yandex.clickhouse.ClickHouseDriver
                    url: jdbc:clickhouse://xxxx:31000/hbdq_eems
                    initialSize: 10
                    maxActive: 100
                    minIdle: 10
                    maxWait: 6000
                    username: xxx
                    password: xxx
    redis:
        # 地址
        host: xxx
        # 端口,默认为6379
        port: xxx
        # 数据库索引
        database: 0
        # 密码
        password:xxx
        # 连接超时时间
        timeout: 10s
        lettuce:
            pool:
                # 连接池中的最小空闲连接
                min-idle: 0
                # 连接池中的最大空闲连接
                max-idle: 8
                # 连接池的最大数据库连接数
                max-active: 8
                # #连接池最大阻塞等待时间(使用负值表示没有限制)
                max-wait: -1ms




版权声明:本文为weixin_37802210原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。