当前位置:主页 > 软件编程 > JAVA代码 >

springboot2.0.0配置多数据源出现jdbcUrl is required with driverClassName的错误

时间:2021-06-11 08:10:45 | 栏目:JAVA代码 | 点击:

 在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方法。

您可能感兴趣的文章:

相关文章