嗨我有一個簡單的UserDetails類與@entity批註,並在我的hibernate配置文件中,hbm2ddl設置爲創建,但運行時顯示錶UserDetails不存在。我創建了表之後,它工作正常。爲什麼休眠不創建自動錶格甚至就是hbm2ddl設置爲創建? 的hibernate.cfg.xmlhiberante hbm2ddl創建屬性不起作用
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/shammu</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="cache.provider_class">org.hibernate.cache.NocacheProvider</property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl">create</property>
<mapping class="org.shammu.UserDetails" />
</session-factory>
</hibernate-configuration>
這裏我們展示你的Hibernate配置文件 –
加入我的配置文件,請參考 – Shameer
它認爲你需要:hibernate.hbm2ddl.auto =創建。 見:http://stackoverflow.com/questions/438146/hibernate-hbm2ddl-auto-possible-values-and-what-they-do –