hibernate连接mysql,出现这样的错误提示,数据库就是不自动建表

2025-05-10 11:57:39
推荐回答(5个)
回答1:

Specified key was too long; max key length is 767 bytes

指定的主键字段太长,最大的主键长度是767 bytes

回答2:

可能 是你的配置文件User有问题参考一下

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">



com.mysql.jdbc.Driver
jdbc:mysql://localhost/hibernate_first
root
root
org.hibernate.dialect.MySQLDialect
true
update






=============================
User.hbm.xml

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
















回答3:

user是mysql的关键字,换个名字试试

回答4:

为什么要用hibernate来建表呢?

回答5:

hbm2dll.auto属性设为true了么?