• 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
  • 相关阅读:
    通过代码获取log4net的文件路径
    关键字后面不加空格
    ASP.NET MVC 4 Content Map
    ASP.NET Overview
    ASP.NET 4 and Visual Studio 2010
    Newtonsoft.Json
    ASP.NET MVC
    log4net
    AutoMapper introduction
    ajax jsonp跨域
  • 原文地址:https://www.cnblogs.com/wangxiayun/p/10069848.html
Copyright © 2020-2023  润新知