0
点赞
收藏
分享

微信扫一扫

jdbcUrl is required with driverClassName错误解决


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配置多数据源:

jdbcUrl is required with driverClassName错误解决_mysql


改为:

jdbcUrl is required with driverClassName错误解决_ico_02

server:
port: 8080
spring:
main:
allow-bean-definition-overriding: true
datasource:
admin: # sys-admin
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/sys-admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
username: root
password: 123456
order: # sys-order
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/sys-order?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
username: root
password: 123456

server:
port: 8080
spring:
main:
allow-bean-definition-overriding: true
datasource:
admin: # sys-admin
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/sys-admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
username: root
password: 123456
order: # sys-order
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/sys-order?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
username: root
password: 123456


举报

相关推荐

0 条评论