• 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配置多数据源:
    在这里插入图片描述
    改为:
    在这里插入图片描述

    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
      application:
        name: mayikt-order
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    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
      application:
        name: mayikt-order
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
  • 相关阅读:
    神经网络中的算法-梯度下降算法的优化
    【SA8295P 源码分析】89 - QNX AIS Camera qcarcam_test 可执行程序 main() 函数 源代码流程分析
    分布式应用全链路跟踪实现
    MySQL的卸载
    数据结构_第一章 绪论
    yolov5
    01OpenCV 加载图片并显示图片
    状态模式详解
    i18n在VUE3中使用插槽动态传入组件
    【操作系统】基础知识概述
  • 原文地址:https://blog.csdn.net/weixin_40816738/article/details/126823798