manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB'

在使用Hibernate建表时出现如下错误

八月 05, 2017 10:52:33 下午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 9

这个问题就出在type=InnoDB

是因为有些有些mysql不知道这种写法,我们可以查看创建表的语句也会发现他在创建表的最后加上了 type=InnoDB

解决方法也很简单,这种情况我们只需要修改方言就可以了

我们可以将下面的方言

<prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>

修改为

<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>

重启项目,创建表成功


如果我们是直接创建表,可以直接将type改成engine


爆款云服务器s6 2核4G 低至0.46/天,具体规则查看活动详情Blog Img