hibernate的xml配置(hibernate-5.0.7)
<!-- 约束文件 -->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<!-- hibernate配置 -->
<hibernate-configuration>
<session-factory>
<!--配置数据库信息是必须的;h1是数据库名称 -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql:///mydatabase</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<!--第二部分:配置hibernate信息的 -->
<!-- 显示sql语句 -->
<property name="hibernate.show_sql">true</property>
<!-- 格式化sql语句 -->
<property name="hibernate.format_sql">true</property>
<!-- 自动创建表 -->
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- 方言 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 获取当前线程的session -->
<property name="hibernate.current_session_context_class">thread</property>
<!-- 引入实体类映射 -->
<mapping resource="实体类配置的xml"/>
</session-factory>
</hibernate-configuration>