JAVA (spring boot) 多数据源配置

1.在启动文件加上

@SpringBootApplication(scanBasePackages = "cn.medbanks",exclude = { DruidDataSourceAutoConfigure.class }

2.在maven文件中添加多数据源依赖

    com.baomidou

    dynamic-datasource-spring-boot-starter

    3.0.0

3.在bootstrap-dev.yml中添加

#数据库配置

  datasource:

    dynamic:

      primary: master

      strict: false

      datasource:

        master:

          url: jdbc:mysql://url?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8

          username: root

          password: 123456

          driver-class-name: com.mysql.jdbc.Driver

        data_warehouse:

          url: jdbc:mysql://url?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8

          username: root   

          password: 123456

          driver-class-name: com.mysql.jdbc.Driver

你可能感兴趣的:(JAVA (spring boot) 多数据源配置)