我正在开发一个 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')
}
我想在 init 上运行 sql:
SET NAMES 'utf8mb4'
支持emoji读/写
我在 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'
但我无法让它工作,并且在应用程序启动时没有关于此的日志。
最佳答案
我想我找到了答案,根据这个answer :
正确的属性将是:
spring.datasource.tomcat.initSQL=SET NAMES 'utf8mb4'
然后这将在连接时执行。
关于spring-boot - 我如何在 Spring Boot-1.4.1-RELEASE 中制作 init-sql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40527477/