一、關鍵在hibernate.cfg.xml的配置中出現如下問題
解決方法:將驅動JAR包手動添加到module的dependences依賴中或者添加到Libraries中
File—>project structure—>Modules
File—>project structure—>Libraries
二、當在hibernate.cfg.xml的配置中設置
<!-- 生成數據庫的表結構 update:如果沒有表結構,創建表結構。如果存在,不會創建,添加數據 --> <property name="hibernate.hbm2ddl.auto">update</property>
時,並沒有自動去創建一張新表。
解決方法:mysql驅動的版本問題需要修改數據庫方言版本,將數據庫方言配置中的
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
改爲
org.hibernate.dialect.MySQL5Dialect