以Hibernate3.6的版本为例
一、文件 ---> 项目结构--->模块 --->添加模块(点绿色的+)--->java模块 --->下一步
二、项目下要创建 config目录(标记为源根 配置文件) 和 lib目录(jar包)
(图中圈的是必要的 其余看需求使用 )
以上jar包在hibernate官方文档的lib目录下(步骤如下 红框圈出的)
三、打开项目结构点开依赖 点绿色“+ ” 找到你项目的位置 将下面的lib目录选中点击“确定 ”“应用”
四、在config目录下创建 hibernate.cfg.xml中配置文件
<?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.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>//数据库连接
<property name="hibernate.connection.url">jdbc:mysql://localhost:33