hibernate配置文件
- 将对象映射为数据库的关系可以采用注解或配置文件,我们先接触配置文件
- 配置文件默认命名为hibernate.cfg.xml,改名的话需要另外指定;默认位置为src下。
先在以上命名文件中配置好数据库连接、方言设置,指定是否打印sql语句、更新表结构方式的方法和映射文件
<?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="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/hibernate</property> <property name=