默认创建数据表使用的引擎是MyISAM

2018-05-14 14:16:37.283  INFO 7328 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
Hibernate: drop table if exists hua_yang_area
Hibernate: drop table if exists model_entity
Hibernate: create table hua_yang_area (id bigint not null auto_increment, create_date datetime not null, create_id varchar(255) not null, uid varchar(255) not null, update_date datetime, update_id varchar(255), area_name varchar(255) not null, area_person bigint not null, primary key (id)) engine=MyISAM
Hibernate: create table model_entity (key1 varchar(255) not null, key2 varchar(255) not null, key3 varchar(255) not null, password varchar(255), user_name varchar(255), primary key (key1, key2, key3)) engine=MyISAM

配置和之前spring boot中一样

server.port=

#datasource
spring.datasource.continue-on-error=false
spring.datasource.url=jdbc:mysql://localhost:3306/swapping?useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.jpa.database=mysql
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

但是如上所示,创建的mysql数据表 引擎为MyISAM

如果想创建时使用InnoDB引擎的话,需要在配置上加上【并且注意,要将方言删除】

添加这一句:
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect 删除这一句:
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

重新启动:

===========================================================

完整配置如下:

server.port=9666

#datasource
spring.datasource.continue-on-error=false
spring.datasource.url=jdbc:mysql://localhost:3306/swapping?useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.jpa.database=mysql
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

==========================================================

为什么使用InnoDB引擎,而不用MyISAM引擎?

因为前者支持事务,而后者不支持事务。

=========================最后,补充一点,这个和什么时候用有关系===================================

在上面配置中采用不同的方言,就能在创建数据表的时候使用不同的引擎去创建。

但是去查看源码,发现

MySQL5InnoDBDialect

已经被废弃了。

最后找到 其实  MySQL57Dialect 和 MySQL55Dialect

就可以创建InnoDB引擎。

所以就根据mysql的版本,采用合适的方言策略即可。例如,我是用的mysql5.5的所以就最后使用

最新文章

  1. dubox首次调用消费者执行两次问题
  2. 【转】如何提高意志力&如何坚持每天学习
  3. 高精度快速预览打开dwg文件的CAD控件CAD Image DLL介绍及下载
  4. hibernate继承(转)
  5. 基本概率分布Basic Concept of Probability Distributions 5: Hypergemometric Distribution
  6. [工具类]文件或文件夹xx已存在,则重命名为xx(n)
  7. Java中的异常处理(二)
  8. 用F340 GPIO做I2C
  9. error C2065: 'assert' : undeclared identifier
  10. 关于Axis 1.4 环境的搭建问题
  11. java 数据结构 栈的实现
  12. 在R中整理数据
  13. Java对字符串加密并返回星号※
  14. Docker容器安装
  15. 总结TCP为什么三次握手四次挥手
  16. powerdesigner 字段添加注释和默认值
  17. jenkins 邮箱配置---腾讯企业邮箱
  18. Java工程师 必须掌握的知识点
  19. hdu 1558 (线段相交+并查集) Segment set
  20. maven 添加jar到中央/远程仓库

热门文章

  1. .export*读取图片
  2. Thread 多线程 同步
  3. 201621123034 《Java程序设计》第8周学习总结
  4. 一键GHOST
  5. 文件搜索工具everything
  6. HDU1285 裸的拓扑排序
  7. struts2中的文件上传和文件下载
  8. 更改mvc版本的时候,手动修改交3.0改到4.0,将razor改到2.0,仍然提示出现错误,mvc3.0
  9. 【问题帖】压缩图片大小至指定Kb以下
  10. API函数的学习与运用