我正在开发一个使用 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
感谢您的帮助。
最佳答案
嗯,自 MariaDB 10.2 以来,InnoDB 被用作默认和最佳选择。这些是他们的 site 上提到的原因
XtraDB had many great improvements over InnoDB in 5.1 and 5.5. But over time, MySQL has implemented almost all of them. InnoDB has caught up and XtraDB is only marginally better...
In particular, the only real improvement that XtraDB 5.7 seems to have is for a write-intensive I/O-bound workload, where innodb_thread_concurrency control is disabled.
因此,对于那些使用最新版本的 MariaDB 的人来说,没有更多理由切换到 XtraDB。
关于mysql - 在 Spring Boot 和 Hibernate 应用程序中使用 XtraDB 作为存储引擎,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51525275/