【spring boot】spring boot 2.0 项目中使用mysql驱动启动创建的mysql数据表,引擎是MyISAM,如何修改启动时创建数据表引擎为【spring boot 2.0】
默认创建数据表使用的引擎是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的所以就最后使用

【spring boot】spring boot 2.0 项目中使用mysql驱动启动创建的mysql数据表,引擎是MyISAM,如何修改启动时创建数据表引擎为【spring boot 2.0】的更多相关文章
- 在Springboot2.0项目中使用Druid配置多数据源
在Springboot出现之前配置数据源以及相关的事物,缓存等内容一直是个繁琐的工作,但是Springboot出现后这些基本都可以靠默认配置搞定,就变得很轻松了.这就是现在推崇模板>配置的原因, ...
- ASP.NET CORE MVC 2.0 项目中引用第三方DLL报错的解决办法 - InvalidOperationException: Cannot find compilation library location for package
目前在学习ASP.NET CORE MVC中,今天看到微软在ASP.NET CORE MVC 2.0中又恢复了允许开发人员引用第三方DLL程序集的功能,感到甚是高兴!于是我急忙写了个Demo想试试,我 ...
- vue2.0项目中使用Ueditor富文本编辑器示例
最近在vue项目中需要使用富文本编辑器,于是将Ueditor集成进来,作为公共组件. 在线预览:https://suweiteng.github.io/vue2-management-platform ...
- 如何在vue2.0项目中引用element-ui和echart.js
1 项目中怎样添加elment-ui 和 echart.js 1.1直接在packjson 里面的 dependencies 配置 "element-ui": "^1.3 ...
- Vue cli2.0 项目中使用Monaco Editor编辑器
monaco-editor 是微软出的一条开源web在线编辑器支持多种语言,代码高亮,代码提示等功能,与Visual Studio Code 功能几乎相同. 在项目中可能会用带代码编辑功能,或者展示代 ...
- 把VueThink整合到已有ThinkPHP 5.0项目中
享 关键字: VueThink ThinkPHP5.0 Vue2.x TP5 管理后台扩展 VueThink初认识 VueThink,是一个很不错的技术框架,由广州洪睿科技的技术团队2016年研发( ...
- maven新建Spring MVC + MyBatis + Oracle的Web项目中pom.xml文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- vue2.0项目中 localhost改成ip地址访问
这里 你可以写成你的ip 那你的项目只能ip访问了,但是写成0.0.0.0的话 你既可已localhost 访问也可以ip访问 也可以写成 127.0.0.1也可以,也能local访问了和ip访问( ...
- vue2.0项目中使用Ueditor富文本编辑器应用中出现的问题
1.如何设置config中的内容 readonly:true,//只读模式wordCount:false,//是否开启字数统计enableAutoSave: false,//自动保存功能 重点:ena ...
随机推荐
- jquery.color.js
经过测试,可以使用. 2016-12-22 21:39:45 /*! * jQuery Color Animations v2.1.2 * https://github.com/jquery/jqu ...
- MSHflexgrid控件删除选中行
相应的代码: Private Sub some_Click() '定义变量 Dim txtSQL As String Dim MsgText As String Dim Online_mrc As A ...
- sqlserver 汉字转拼音 首写字母 索引 函数
create function fun_getPY(@str nvarchar(4000)) returns nvarchar(4000) as begin declare @word nchar(1 ...
- 多线程 线程池 ExecutorService
package org.zln.thread; import java.util.Date; import java.util.concurrent.ExecutorService; import j ...
- Centos 6.5 HISTSIZE更改
通过 更改 /etc/profile 中的HISTSIZE值,改完之后,执行source /etc/profile 和echo $HISTSIZE,结果还是之前的HISTSIZE值, 解决办法:执行 ...
- oracle的隐式游标
游标的概念: 游标是SQL的一个内存工作区,由系统或用户以变量的形式定义.游标的作用就是用于临时存储从数据库中提取的数据块.在某些情况下,需要把数据从存放在磁盘的表中调到计算机内存中进行处理, ...
- webpack最佳入门实践系列(5)
9.路径相关 原来我们打包的东西都存放到了dist目录下,并没有进行分类存储,乱成一团,这一节我们就要处理一下打包的路径,让打包后的目录看起来更加优雅 9.1.代码准备 我们先建立起这样一个目录结构 ...
- <a></a>的href属性失效
<a href="javascript:void(0);" class="close">关闭</a>
- Computer(hdu 2196)
题意:给出一棵树,求出每个点与距离它最远的点的距离. /* 树形DP 先把无根树转为有根树,对于一个节点i来说,与它相距最远的点有两种可能,一是在它的子树中,二是不在,我们分别用f[i][0]和f[i ...
- 免费的二维码发布平台 http://zhifubao.masao.top:8282/assets/index.html
http://zhifubao.masao.top:8282/assets/index.html