springboot配置多数据库

#数据源配置
jdbc:
  #系统库
  master:
    host: *
    port: *
    db: *
    user: *
    passwd: *
  slave:
    host: *
    port: *
    db: *
    user: *
    passwd: *
  #格式化SQL语句(true:开启[有性能损失],false:关闭)
  p6spy: true
spring:
  #启动banner
  banner:
    location: classpath:config/banner.txt
  #默认配置文件
  profiles:
    active: dev
  servlet:
    multipart:
      #文件上传大小设置
      enabled: true
      max-file-size: 1024MB
      max-request-size: 1024MB
  #热部署
  devtools:
    restart:
      enabled: false
  #排除DruidDataSourceAutoConfigure类
  autoconfigure:
    exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
  #数据源
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      stat-view-servlet:
        loginUsername: admin
        loginPassword: Ppnn13y
      initial-size: 3
      max-active: 8
      min-idle: 1
      max-wait: 6000
      min-evictable-idle-time-millis: 30000
      max-evictable-idle-time-millis: 30000
      time-between-eviction-runs-millis: 60000
      validation-query: select 1
      validation-query-timeout: -1
      test-on-borrow: false
      test-on-return: false
      test-while-idle: true
      pool-prepared-statements: true
      filters: stat,wall
    dynamic:
      #默认数据库
      primary: master
      #格式化SQL语句(true:开启[有性能损失],false:关闭)
      p6spy: ${jdbc.p6spy}
      datasource:
        master:
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://${jdbc.master.host}:${jdbc.master.port}/${jdbc.master.db}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
          username: ${jdbc.master.user}
          password: ${jdbc.master.passwd}
        slave:
          driver-class-name: oracle.jdbc.driver.OracleDriver
          url: jdbc:oracle:thin:@//${jdbc.slave.host}:${jdbc.slave.port}/${jdbc.slave.db}
          username: ${jdbc.slave.user}
          password: ${jdbc.slave.user}
@DS("slave")
@Override
public List findV3ApmsgList(String queryDate,String limit) {
    return v3ApmsgMapper.selectData(DateUtils.toDate(queryDate,DateUtils.YYYY_MM_DD_HH_MM_SS),limit);
}

https://www.cnblogs.com/aizen-sousuke/p/11756279.html

你可能感兴趣的:(技术使用总结,知识总结,jdbc)