spring boot 配置启动后执行sql, 中文乱码
spring.datasource.schema指定启动后执行的sql文件位置。
我发现中文乱码,原因是没有指定执行sql script encoding:
spring:
datasource:
url: "jdbc:h2:mem:test"
username: "sa"
password: ""
schema: database/import.sql
sql-script-encoding: utf-8
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: org.h2.Driver
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat
关注我的公众号
![](https://images2018.cnblogs.com/blog/686418/201808/686418-20180822091328437-1109977663.jpg)