springboot配置多数据源

依赖:

<dependency>
       <groupId>com.baomidou</groupId>
       <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
     <version>3.3.2</version>
   </dependency>

application.yml

spring:
  datasource:
    dynamic:
      primary: master
      strict: true
      datasource:
        master: # 第一个数据源的配置
          driver-class-name: your-driver-class-name-1
          url: jdbc:your-database-url-1
          username: your-username-1
          password: your-password-1
        slave: # 第二个数据源的配置
          driver-class-name: your-driver-class-name-2
          url: jdbc:your-database-url-2
          username: your-username-2
          password: your-password-2

你可能感兴趣的:(spring,boot,java,mybatis)