【问题标题】:Setting Hibernate Dialect not working with Spring and YML config设置休眠方言不适用于 Spring 和 YML 配置
【发布时间】:2017-06-10 09:15:44
【问题描述】:

这是我的配置:

spring.jpa:
  hibernate:
    ddl-auto: update
    connection:
      charset: utf8
      useUnicode: true
  properties.hibernate.dialect: org.hibernate.dialect.MySQL5InnoDBDialect

根据我在 docs 和 SO 中找到的内容,它应该可以工作,但仍然使用 MyISAM 而不是 InnoDB 创建新表。

我的配置有什么问题?

【问题讨论】:

    标签: spring hibernate spring-boot


    【解决方案1】:

    设置方言的属性其实是spring.jpa.properties.hibernate.dialect

    试试这个:

    spring.jpa: 
      hibernate: 
        connection: 
          charset: utf8
          useUnicode: true
        ddl-auto: update
      properties.hibernate.dialect: org.hibernate.dialect.MySQL5InnoDBDialect
    

    Spring boot sample供参考

    【讨论】:

    • 根据您的帖子更新了配置,但在启动应用程序表时仍然使用 MyISAM...
    • 我克隆了我链接到的示例项目并将方言设置为 innodb,因为该示例使用了另一个。运行它,spring 使用Engine: InnoDB 创建了表
    【解决方案2】:

    在您的 application.yml 中提供以下更改

    spring.datasource: 网址:jdbc:mysql://?verifyServerCertificate=false&useSSL=true&requireSSL=false 用户名: 密码:

    spring.jpa: 特性: 休眠: 方言:org.hibernate.dialect.MySQLDialect

    它会起作用的:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-21
      • 2018-12-16
      • 2016-11-06
      • 2014-11-05
      • 2021-12-17
      • 1970-01-01
      • 2011-05-03
      • 1970-01-01
      相关资源
      最近更新 更多