在Spring Boot 2.0配置多数据源和Spring Boot 1.5.x之前,一些配置及用法多少有些不同,其中一个问题就是“jdbcUrl is required with driverClassName.”的错误
解决办法:
在配置文件中使用spring.datasource.jdbc-url,而不是通常使用的spring.datasource.url
spring: datasource: master: jdbc-url: jdbc:postgresql://192.168.1.2:5432/test?useUnicode=true&characterEncoding=utf8 username: postgres password: postgres driverClassName: org.postgresql.Driver maxActive: 10 maxIdle: 3 worker: jdbc-url: jdbc:postgresql://192.168.1.3:5432/test?useUnicode=true&characterEncoding=utf8 username: postgres password: postgres driverClassName: org.postgresql.Driver maxActive: 10 maxIdle: 3
第二种方法:
在数据源配置时使用DataSourceProperties方法。