<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 配置数据信息 --> <!--加载数据库驱动 --> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <!--配置本地数据库 --> <property name="hibernate.connection.url">jdbc:mysql:///hibernate_day03</property> <!-- 配置数据账号 --> <property name="hibernate.connection.username">root</property> <!--配置数据密码 --> <property name="hibernate.connection.password">123</property> <!-- 配置hibernate信息 可选 --> <!-- 输出sql语句 --> <property name="hibernate.show_sql">true</property> <!-- 格式化sql语句 --> <property name="hibernate.format_sql">true</property> <!-- hibernate帮创建表 需要配置后 update:如果已经存在表,更新,如果没有 创建表 --> <property name="hibernate.hbm2ddl.auto">update</property> <!-- 配置数据库方言 --> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <!-- 把映射文件放到核心配置文件中 --> <property name="hibernate.current_session_context_class">thread</property> <mapping resource="com/wushuisheng/entity/Customer.hbm.xml"/> <mapping resource="com/wushuisheng/entity/LinkMan.hbm.xml"/> <!-- <mapping resource="com/wushuisheng/manytomany/Role.hbm.xml"/> <mapping resource="com/wushuisheng/manytomany/User.hbm.xml"/> --> </session-factory> </hibernate-configuration>