一 配置
spring.datasource.primary.url=jdbc\:mysql\://localhost\:3306/test?useUnicode\=true&characterEncoding\=utf-8
spring.datasource.primary.username=test
spring.datasource.primary.password=123456
spring.datasource.primary.driver-class-name=com.mysql.jdbc.Driver
#验证连接的有效性
spring.datasource.primary.test-while-idle=true
#获取连接时候验证,会影响性能
spring.datasource.primary.test-on-borrow=false
#在连接归还到连接池时是否测试该连接
spring.datasource.primary.test-on-return=false
spring.datasource.primary.validation-query=SELECT 1 FROM DUAL
#空闲连接回收的时间间隔,与test-while-idle一起使用,设置5分钟
spring.datasource.primary.time-between-eviction-runs-millis=300000
#连接池空闲连接的有效时间 ,设置30分钟
spring.datasource.primary.min-evictable-idle-time-millis=1800000
spring.datasource.primary.initial-size=5
#指定连接池中最大的活跃连接数.
spring.datasource.primary.max-active=50
#指定连接池等待连接返回的最大等待时间,毫秒单位.
spring.datasource.primary.max-wait=60000
#指定必须保持连接的最小值
spring.datasource.primary.min-idle=5
spring.datasource.secondary.url=jdbc\:mysql\://localhost\:3306/test2?useUnicode\=true&characterEncoding\=utf-8
spring.datasource.secondary.username=test
spring.datasource.secondary.password=123456
spring.datasource.secondary.driver-class-name=com.mysql.jdbc.Driver
#验证连接的有效性
spring.datasource.secondary.test-while-idle=true
#获取连接时候验证,会影响性能
spring.datasource.secondary.test-on-borrow