zoukankan      html  css  js  c++  java
  • SpringBoot2.x整合JDBC及初始化data.sql和schema.sql脚本

    今天在使用SpringBoot2.x版本整合JDBC时遇到了一些问题;由于我之前一直用SpringBoot1.5的版本,所以直接在yml里按照1.5的版本配置了属性,没想到2.x直接不能用了。首先是数据库驱动改变了:

    Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is
    generally unnecessary.


      以前的驱动
    jdbc.driverClass = com.mysql.dbc.Driver

    现在的驱动

    jdbc.driverClass = com.mysql.cj.jdbc.Driver

    然后是自动初始化sql脚本的问题,1.5的版本只要将脚本命名为schama-*.sql,放在classpath下启动项目就能自动执行该脚本语句,到了2.x版本则需要增加如下配置:

    schema-username: root
    schema-password: 123456
    data-username: root
    data-password: 123456
    platform: mysql
    schema: classpath:schema-*.sql
    continue-on-error: true
    initialization-mode: always
  • 相关阅读:
    9 Fizz Buzz 问题
    2 尾部的零
    1 A+B问题
    递归
    互斥同步
    垃圾收集器与内存分配策略---垃圾收集算法
    10.矩形覆盖
    9.变态跳台阶
    8.跳台阶
    9.path Sum III(路径和 III)
  • 原文地址:https://www.cnblogs.com/wangxiayun/p/10069848.html
Copyright © 2011-2022 走看看