1.show Data Source Explore
->window->show view->Data Source Explorer(如果没有存在则在other中选择)
选择后会多一个view-Data Source Explorer
2.在Data Source Explore视图中选中Database Connections
->Database Connection->new(出现Connection Profile对话框)
->在Connection Profile Types框中选择->MySQL(在下面Name框中可以为这个数据库链接命名)
->此时跳转到Specify a Driver and Connection Details对话框
->在这个兑换的Drivers选择相应的数据库驱动及数据库链接信息
->第一次需要点击Drivers右侧的星型带圈的图案
->在Name/Type选择驱动的版本号->在JAR List中选择相应的驱动jar包
->此时点击Finsish
此时数据库链接完成了
3.生成实体类配置
->单击项目的右键->点击Properties->Project Facets->Convert to faceted form...
->选中复选框JPA->点击Further Configuration required...->弹出JPA Facet
->在JPA Implemention 的Type下拉框选择Disable Library Configuration
->在Connection选择刚刚建立的驱动
->勾选Add driver library to build path
->勾选Override default schema from connection
->点击OK
4.生成实体
->点击项目右键出现JPA Tools->选择Generate Entities from Tables...->选择Connection和Scheme->勾选需要生成实体的数据库表->Finish