1.eclipse配置hibernate环境java
因为在公司中不能在线安装jboss Tools,只能简单介绍手动安装mysql
在jboss官网下载对应本身eclipse的压缩包。sql
在eclipse 中选择Help-->Install New SoftWare ---> Add--->Archive 选择本身刚下载的jboss Tools zip包。数据库
只需安装hibernate tools就好,而后一路next ,finish.app
2.检测有没有安装好eclipse
window --> show view -->other--->Hibernate 若有Hibernate选项,就说明安装好了工具
3.链接数据库编码
window-->show view-->other-->Data Management-->Data Soure Explorerhibernate
右击Database Connections -->new xml
选择本身的数据库,我选择的是MySQL
本身的链接和帐号密码
点击finish 出现
出现mysql的链接,表示链接数据库成功。
4.在工具栏空白处右击 选择Customize Perspective(不知道为何上不了图了,只能文字了)
选择 Command groups Availability 在左边选择Hibernate Code Generation 选项,单击OK.
5.建立配置文件
选择图中最右边按钮,选择Hibernate Code Generation Configurations--->(不知道该怎么吐槽了,又不能上图了)
选择弹出框的右边列表 Hibernate Code Generation 右击,选择new
选择输入的项目地址,填写报名,勾选Reverse engineer from JDBC Connection,而后建立hibernate.reveng.xml
选择文件的位置,选择next
Refresh出现本身的数据库,把想要生成的表,include到右边,finish.
而后
在Exporters 中选择 Domain caode(.java) 和 Hibernate XML Mappings(.hbm.xml)选项,在Common选项中编码选择UTF-8,单击run