---
title: "eclipse配置hibernate环境"
author: "zhb8015"
date: "2015-12-07T23:12:25Z"
tags: []
categories: ["企业架构"]
slug: "eclipse-hibernate"
draft: false
lastmod: "2015-12-07T23:13:17Z"
id: 2262452
url: "https://peter8015.iteye.com/blog/2262452"
---

**hibernate插件安装方法：**

http://download.jboss.org/jbosside/updates/stable

 

1. 点击eclipse的help菜单里的“Install New Software”
2. 点击“Add”，输入下面的内容，一路“NEXT”即可

 

hibernate更新网址：

http://download.jboss.org/jbosside/updates/stable

![](http://dl.iteye.com/upload/attachment/0082/9462/66dc7e86-8ce0-31ec-ac72-4b8536f190d6.jpg "点击查看原始大小图片")

 

或者通过其他渠道手动下载插件包：

 

步骤一：下载Hibernate插件（建议手动安装）

到官网上下，我下的是HibernateTools-3.3.0.v201003050540R-H56-GA .rar

解压后将里面的plugins文件夹下的所有文件拷贝到eclipse的dropins文件夹下。启动eclipse你会发现有hibernate的插件出现了，然后设置一下显示。

 步骤二：下载hibernate3.rar

解压下来后会发现hibernate3.jar,将它拷贝到项目文件夹所在的lib下。同时将hibernate解压文件下的需要的lib也拷贝到项目文件夹所在的lib下。

 

步骤三：建数据库和表

如数据库名：demo，数据表userinfo

步骤四：建立hibernate.cfg.xml（file-&gt;新建-&gt;other-hibernate文件夹下的：cfg.xml,然后根据数据源设置好点完成即可）

步骤五：window-&gt;Customize Perspective-&gt;Command Groups Availability-&gt;选中Hibernate Code Generations 点确定即可。接着在界面run hibernate.reveng.xml下拉框中选择并打开Hibernate Code Generations，设置一下。

具体:

1选Console condifuration(如果已经配置了hibernate.cfg.xml就会出现相关的下拉框)即项目名称

2设置Output directory(即放置的路径)

3选中Reverse engineer for JDBC Connection

4设置Reveng.xml（注意要refresh才会出现数据源，include数据表）

最后点击确定即可自动生成相关的hbm.xml和pojo文件.以及配置文件hibernate.reveng.xml

 

以下是转载过来的图文教程：

 

 

**1.下载hibernatetools插件**

 

hibernatetools可从官网下载，但是需要注意下载和自己使用的eclipse版本对应的版本包，然后安装到eclipse中取，link安装方式参见：[http://maimode.iteye.com/blog/1164524](http://maimode.iteye.com/blog/1164524)

 

**2.创建hibernate配置文件及console配置文件**

 

新建java项目，建立包test,test.hibernate,test.model。

选中项目，右键-》new-》other-》hibernate-》hibernate configuration file：

![](http://dl.iteye.com/upload/attachment/0072/2402/86648b10-14bd-39bc-93f1-f18fe02a8884.png)

 

然后 next，配置console文件：

![](http://dl.iteye.com/upload/attachment/0072/2406/eb513bb7-e4d9-3471-aacb-7cf7d5a5c4eb.png)

 

 

**3.创建reverse文件**

 

选中项目，右键-》new-》other-》hibernate-》hibernate reverse engineering file

![](http://dl.iteye.com/upload/attachment/0072/2412/353f0496-995d-3d3b-a28f-27326381ca58.png)

 

下一步，配置要生成POJO对应的表：

![](http://dl.iteye.com/upload/attachment/0072/2783/31d94b53-caec-358d-8e9b-f1837b9d1a54.png)

 

**4.反向工程创建pojo**

 

在hibernate code generation configuration菜单中配置

![](http://dl.iteye.com/upload/attachment/0072/2418/a98128bd-4ec9-3a7d-adfa-f5dfc08b7225.png)

 

![](http://dl.iteye.com/upload/attachment/0072/2410/6467b8aa-d9d4-3136-aad8-de1d374f8ec5.png "点击查看原始大小图片")

 

![](http://dl.iteye.com/upload/attachment/0072/2408/d4e1be82-167e-3570-b9ab-9465d2b6de5b.png "点击查看原始大小图片")

 

*执行run后便生成了相应的pojo文件：*

 

![](http://dl.iteye.com/upload/attachment/0072/2422/3f98db03-072d-3cb5-bd7e-b12e5ac08229.png)

 

 

一般自动生成的mapping文件（XXX.hbm.xml）都需要修改后才能使用。

 

这样就可以完成安装Hibernate插件和开发Hibernate程序了

 

 

# [eclipse从数据库逆向生成Hibernate实体类(eclipse中反向生成hibernate实体类+jpa注释)](http://www.ityuedu.com/article/6221932824/;jsessionid=1EF43994ECAACB11DC51E386D22F5A30)