如何在Spring Boot-1.4.1-RELEASE中创建init-sql

kvh*_*kvh 1 spring-data spring-data-jpa spring-boot

我正在开发一个spring boot应用程序:

使用依赖项:

    dependencies {
    compile("org.springframework.boot:spring-boot-starter-web:1.4.1.RELEASE")
    compile('org.springframework.boot:spring-boot-starter-data-jpa:1.4.1.RELEASE')
    compile('mysql:mysql-connector-java:5.1.39')
}
Run Code Online (Sandbox Code Playgroud)

我想在init上运行sql:

SET NAMES 'utf8mb4'
Run Code Online (Sandbox Code Playgroud)

支持表情符号读/写

我在application.properties上进行了这些配置

spring.datasource.tomcat.init-sql=SET NAMES 'utf8mb4'
spring.datasource.init-sql=SET NAMES 'utf8mb4'
spring.datasource.connection-init-sql=SET NAMES 'utf8mb4'
Run Code Online (Sandbox Code Playgroud)

但我无法使它工作,并且在应用程序启动时没有这个日志.

kvh*_*kvh 5

根据这个答案,我想我找到了答案:

正确的属性将是:

spring.datasource.tomcat.initSQL=SET NAMES 'utf8mb4'
Run Code Online (Sandbox Code Playgroud)

然后这将执行连接.