使用hibernate的时候不能自动建表,有几种方法排除
1.确定hibernate的包的导入
2.在hibernate.cfg.xml文件中<property name="hbm2ddl.auto"> 的值为create。这个属性值有几种,当为create 时,为自动建表
3. 在hibernate.cfg.xml文件<property name="dialect"> org.hibernate.dialect.MySQLDialect 的问题,即使是Mysql 数据库,根据引擎的不同有三种方言
org.hibernate.dialect.MySQLDialect
org.hibernate.dialect.MySQLInnoDBDialect
org.hibernate.dialect.MySQLMyISAMDialect
看自己是开了什么引擎,不知道就一个个试一下吧
本文介绍了如何通过配置Hibernate实现数据库表的自动生成。主要涉及配置文件hibernate.cfg.xml中的hbm2ddl.auto属性设置为create,以及正确选择MySQL方言等关键步骤。
3910

被折叠的 条评论
为什么被折叠?



