Hibernate的基本配置
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <!-- Generated by MyEclipse Hibernate Tools. --> <hibernate-configuration> <session-factory> <!-- 指定Hibernate启动的时候自动更新表, 如果不存在则创建--> <property name="hbm2ddl.auto">update</property> <!-- 声明使用的SQL语句是MySQL的,方言的声明--> <property name="dialect"> org.hibernate.dialect.MySQLDialect </property> <!-- 在控制台打印SQL语句--> <property name="show_sql"> true </property> <!-- 使用线程,防止遇到异常--> <property name="current_session_context_class"> thread </property> <!-- 连接信息--> <property name="connection.url"> jdbc:mysql://localhost:3306/test </property> <property name="connection.username">root</property> <property name="connection.password">1</property> <property name="connection.driver_class"> com.mysql.jdbc.Driver </property> <!-- 实体类的映射 --> <mapping resource="com/po/User.hbm.xml" /> </session-factory> </hibernate-configuration>