【发布时间】:2019-01-02 15:35:10
【问题描述】:
我正在开发一个使用 Spring Boot 2.0.3、Hibernate 5.2.17 和 MariaDB 10.1.29 的项目。当hibernate生成表时,我试图将存储引擎设置为XtraDB,但没有成功。
这是我的 application.properties 文件:
spring.thymeleaf.cache=false
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.url=jdbc:mariadb://localhost:3306/bookstore-db
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=****
spring.datasource.hikari.connection-timeout=20000
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=12
spring.datasource.hikari.idle-timeout=300000
spring.datasource.hikari.max-lifetime=1200000
spring.datasource.hikari.auto-commit=true
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB53Dialect
spring.jpa.properties.hibernate.dialect.storage_engine=xtradb
spring.jpa.hibernate.ddl-auto=update
即使指定 spring.jpa.properties.hibernate.dialect.storage_engine=xtradb,它仍然使用 InnoDB,如控制台所示:
create table hibernate_sequence (
next_val bigint
) engine=InnoDB
Hibernate:
insert into hibernate_sequence values ( 1 )
Hibernate:
create table user (
id_user bigint not null,
email varchar(255) not null,
enabled bit not null,
first_name varchar(255),
last_name varchar(255),
password varchar(255),
phone varchar(255),
username varchar(255),
primary key (id_user)
) engine=InnoDB
感谢您的帮助。
【问题讨论】:
-
只使用 InnoDB。
-
问题是对于低于 10.2 的 MariaDB 版本,出于性能原因建议使用 XtraDB link
-
是的,XtraDB 更好。适用于 1% 的应用程序。其他 99% 的人不会注意到显着差异。
-
好吧,我看了你的个人资料,我认为你很有经验,所以我会听取你的建议。
标签: mysql spring hibernate spring-boot mariadb