[超详细]eclipse使用hibernate创建mysql****
参考资料:https://www.cnblogs.com/whjblogs/p/3137385.html。
找了一些资料来参考,没有发现用mysql来做演示的,于是就对着资料补充了一下,希望能帮到需要的人吧。
首先是准备好的项目,然后点开elcipse菜单栏的window->showView->dataSourceExplor
控制台那里出现了新的窗口
点击new,新建一个数据库连接
在出现的数据库列表中选择Mysql,点击next
进入数据库的设置界面,然后点击图中鼠标所在的“+”号
选好自己的mysql版本,可以看到ok是灰色的,因为需要mysql的jar包,我们点击JAR LIST
点击Add JAR/ZIP…
选中mysql连接jar包,可以跟着我上面的路径找,如果找不到就去下载一个再选中。
选完jar包后,再点击properties,填好自己数据库对应的信息,然后点ok点finish
点击Test Connection
出现Ping succeeded!说明数据库连接配置正确。
到这一步就完成了连接mysql的内容了
接下来需要用到一个eclipse的插件,点击菜单栏的help,再点击install new software
上面对应的网址是eclipse mars 4.5版本的插件,如果不是这个版本,可以浏览器进入网站,网址如下图片地址栏所示:
点击下面的链接查看所有的版本插件
选择自己对应的版本就好
选好对应的版本后,按照上图进行网址的复制(我的之前安装过了,没有相关的图了,就拿参考资料里的顶一下),勾选Hibernate Tools插件
勾选完,点击ok,要等一段时间进行插件的下载,下载安装完成后会要求重新启动eclipse,重启后点开eclipse菜单栏window ->Perspective->Customize Perspective…
再在elipse菜单栏里面 window->show View ->找到下图所示的Hibernate插件
在出现的新的窗口空白处右键,选择Add Configuration…
点击finish就可以****,从数据库中的表生成实体了,效果如下: