整体架构:
链接:https://pan.baidu.com/s/1cnMWdaqVwczEiAAAZNWXlw
提取码:1f1o
hibernate核心配置文件:
hibernate.cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- session工厂的配置 -->
<session-factory>
<!-- jdbc配置 -->
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="connection.url">
<!-- url的两种配置方式 -->
<!-- jdbc:mysql://localhost:3306/chat-->
jdbc:mysql:///chat
</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<!-- 数据库方言
hibernate支持多种数据库,通过设置方言hibernate才知道应该
生成对应数据库的sql语句:hibernate支持的数据库的方言hibernate.properties文件中都有
-->
<!-- 指定数据库 -->
<property name="dialect">
org.hibernate.dialect.MySQL5Dialect
</property>
<!-- 打印hibernate生成的sql语句 -->
<property name="show_sql">true</property>
<!-- 格式化打印的sql语句 -->
<property name