【问题标题】:How to create tables as InnoDB in jpa?如何在 jpa 中创建表作为 InnoDB?
【发布时间】:2019-11-29 06:49:09
【问题描述】:

我试图将表创建为 innodb 以使用外键,但我失败了,我的表仍保留为 myIssam 引擎!

我的mysql版本是5.7.26 这是我的 application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/general_security?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=basil
spring.datasource.password=root
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.type=debug
spring.jpa.hibernate.ddl-auto=create
hibernate.dialect.storage_engine=innodb
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

spring.datasource.hikari.maximum-pool-size=50

server.servlet.context-path=/generalSecurity
spring.jmx.default-domain: general_security

我也试过了

spring.jpa.database-platform: org.hibernate.dialect.MySQL5InnoDBDialect

【问题讨论】:

    标签: java mysql spring-boot jpa


    【解决方案1】:

    你可以试试

    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL57Dialect
    spring.jpa.properties.hibernate.dialect.storage_engine=innodb
    

    【讨论】:

    • 效果很好,谢谢。但是为什么我的配置不起作用?
    • 乍一看,您使用了 mysql 5 的配置 ... 不适用于 mysql 5.7 .. 因此不使用错误(或不适用)的参数并使用默认值(myisam)
    • 那太好了,感谢您的帮助和解释
    猜你喜欢
    • 2011-10-28
    • 2015-09-23
    • 1970-01-01
    • 2016-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-29
    • 1970-01-01
    相关资源
    最近更新 更多