springboot 升级到2.0之后发现配置多数据源的时候报错:
“jdbcUrl is required with driverClassName.”或者Cause: java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required.] with root cause
主要原因是在1.0 配置数据源的过程中主要是写成:spring.datasource.url 和spring.datasource.driverClassName。
而在2.0升级之后需要变更成:spring.datasource.jdbc-url和spring.datasource.driver-class-name即可解决!
springboot2.0配置多数据源:
改为:
server:port: 8080
spring:main:allow-bean-definition-overriding: truedatasource:admin: # sys-admindriver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/sys-admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8username: rootpassword: 123456order: # sys-orderdriver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/sys-order?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8username: rootpassword: 123456application:name: mayikt-order
server:port: 8080
spring:main:allow-bean-definition-overriding: truedatasource:admin: # sys-admindriver-class-name: com.mysql.cj.jdbc.Driverjdbc-url: jdbc:mysql://localhost:3306/sys-admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8username: rootpassword: 123456order: # sys-orderdriver-class-name: com.mysql.cj.jdbc.Driverjdbc-url: jdbc:mysql://localhost:3306/sys-order?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8username: rootpassword: 123456application:name: mayikt-order