Springboot接続マルチデータソースjdbcUrl is required with driverClassNameエラー

5809 ワード

学習springboot mybatisを使用してマルチデータソースに接続しようとしたときにjdbcUrl is required with driverClassNameエラーが発生しました.ymlの構成を変更するだけでいいです.
datasource:
    primary:
      jdbc: jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT
      username: zeng
      password: zeng
      driver-class-name: com.mysql.cj.jdbc.Driver
    secondary:
      jdbc: jdbc:mysql://localhost:3306/eesy?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT
      username: zeng
      password: zeng
      driver-class-name: com.mysql.cj.jdbc.Driver

次のように変更
datasource:
    primary:
      jdbc-url: jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT
      username: zeng
      password: zeng
      driver-class-name: com.mysql.cj.jdbc.Driver
    secondary:
      jdbc-url: jdbc:mysql://localhost:3306/eesy?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT
      username: zeng
      password: zeng
      driver-class-name: com.mysql.cj.jdbc.Driver

接続プールを使用していないことに注意してください