使用Eclipse进行Hibernate配置
*所有步骤按照老师视频的顺序进行,过程中遇到的问题已经基本解决。
1.新建Java文件,导入Hibernate文件所需要的类包、连接MySQL所使用的jdbc以及日志类"log4j-1.2.17.jar和slf4j-log4j12-1.7.7.jar。
所需的所有类包如下:
2.在src目录下添加配置文件hibernate.cfg.xml。
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<!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.dialect">MySQLInnoDBDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hellohibernate?serverTimezone=UTC</property>
<property name="hibernate.connection.username">root</property>
<property name="hi