<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- 數(shù)據(jù)庫驅(qū)動 -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- 數(shù)據(jù)庫url -->
<property name="hibernate.connection.url">jdbc:mysql://39.106.1.213:3306/user?characterEncoding=utf-8</property>
<!-- 數(shù)據(jù)庫連接用戶名 -->
<property name="hibernate.connection.username">root</property>
<!-- 數(shù)據(jù)庫連接密碼 -->
<property name="hibernate.connection.password">123456</property>
<!-- 數(shù)據(jù)庫方言
不同的數(shù)據(jù)庫中,sql語法略有區(qū)別. 指定方言可以讓hibernate框架在生成sql語句時.針對數(shù)據(jù)庫的方言生成.
sql99標(biāo)準(zhǔn): DDL 定義語言 庫表的增刪改查
DCL 控制語言 事務(wù) 權(quán)限
DML 操縱語言 增刪改查
注意: MYSQL在選擇方言時,請選擇最短的方言.
-->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 將hibernate生成的sql語句打印到控制臺 -->
<property name="hibernate.show_sql">true</property>
<!-- 將hibernate生成的sql語句格式化(語法縮進(jìn)) -->
<property name="hibernate.format_sql">true</property>
<!--
## auto schema export 自動導(dǎo)出表結(jié)構(gòu). 自動建表
#hibernate.hbm2ddl.auto create 自動建表.每次框架運(yùn)行都會創(chuàng)建新的表.以前表將會被覆蓋,表數(shù)據(jù)會丟失.(開發(fā)環(huán)境中測試使用)
#hibernate.hbm2ddl.auto create-drop 自動建表.每次框架運(yùn)行結(jié)束都會將所有表刪除.(開發(fā)環(huán)境中測試使用)
#hibernate.hbm2ddl.auto update(推薦使用) 自動生成表.如果已經(jīng)存在不會再生成.如果表有變動.自動更新表(不會刪除任何數(shù)據(jù)).
#hibernate.hbm2ddl.auto validate 校驗.不自動生成表.每次啟動會校驗數(shù)據(jù)庫中表是否正確.校驗失敗.
-->
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.id.new_generator_mappings">false</property>
<!-- 引入orm元數(shù)據(jù)
路徑書寫: 填寫src下的路徑
-->
<mapping class="com.hb.demo.entity.SysUser"/>
</session-factory>
</hibernate-configuration>
hibernate.cfg.xml