我如何在 Spring Boot-1.4.1-RELEASE 中创建一个 init-sql [英] How can i make a init-sql in Spring Boot-1.4.1-RELEASE

查看:58
本文介绍了我如何在 Spring Boot-1.4.1-RELEASE 中创建一个 init-sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Spring Boot 应用程序:

I am developing a spring boot application:

使用依赖项:

    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')
}

我想在 init 上运行 sql:

I want to run sql on init:

SET NAMES 'utf8mb4'

支持表情符号读写

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

I make these configs on 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'

但我无法让它工作,而且在应用程序启动时没有记录.

But i can't make it work, and there no log for this on application startup.

推荐答案

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

I think i found the answer, according to this answer:

正确的属性是:

spring.datasource.tomcat.initSQL=SET NAMES 'utf8mb4'

然后这将在连接时执行.

then this will exec on connection.

这篇关于我如何在 Spring Boot-1.4.1-RELEASE 中创建一个 init-sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆