SpringBoot2.0在自动加载类路径下的schema-all.sql文件的时候,自动加载不成功
- 数据库驱动需要更改
driver-class-name: com.mysql.cj.jdbc.Driver
-
需要在配置文件设置
initialization-mode: always
即可成功加载schema-all.sql文件,问题解决!!! -
可以在application.yml属性文件中指定加载的sql文件配置
spring:
datasource:
username: root
password: 123456
url: jdbc:mysql://192.168.1.73:3306/springboot-jdbc
driver-class-name: com.mysql.cj.jdbc.Driver
initialization-mode: always
schema:
- classpath:department.sql