Spring boot 连接多数据源
1.application.yml中添加两个datasource server: port: 8080 spring: application: name: king datasource: master: type: com.zaxxer.hikari.HikariDataSource jdbc-url: jdbc:mysql://localhost:3306/king?useUnicode=yes&characterEncoding=UTF-8&serverTimezone=UTC driver-class-name: com.mysql.cj.jdbc.Driver username: root password: 123456 idle-timeout: 10000 minimum-idle: 1 maximum-pool-size: 10 pool-name: master auto-commit: false connection-test-query: SELECT 1 slave: type: com.zaxxer.hikari.HikariDataSource jdbc-url: jdbc:mysql://localhost:3306/king?useUnicode=yes&characterEncoding=UTF-8&serverTimezone=UTC