[英]How to add JPA tooling to a plain Java project in Eclipse Oxygen?
I'm trying to generate JPA entities from database tables in an Eclipse Oxygen Java EE project.我正在尝试从Eclipse Oxygen Java EE 项目中的数据库表生成 JPA 实体。
Problem is I can't find the JPA context menu, nor I can find the JPA (Java Persistence) facet.问题是我找不到 JPA 上下文菜单,也找不到 JPA(Java Persistence)方面。 How do I manage to do that?
我该如何做到这一点?
To activate JPA tooling in a fresh Eclipse Java project you need to add a so-called Project Facet , as seen in this screenshot: 要在全新的Eclipse Java项目中激活JPA工具,您需要添加一个所谓的Project Facet ,如此屏幕截图所示:
First, right-click on your project folder (for which you want to add JPA support). 首先,右键单击项目文件夹(要为其添加JPA支持)。 Next, select 'Project Facets' from the tree navigation and activate the JPA option, as seen in step 2.
接下来,从树导航中选择“Project Facets”并激活JPA选项,如步骤2中所示。
With a fresh Eclipse installation, ie which has never used a JPA provider (via User Library) locally, you will be asked to setup and download a persistence provider implementation. 使用全新的Eclipse安装,即从未在本地使用JPA提供程序(通过用户库),将要求您设置和下载持久性提供程序实现。 This might also apply for new/different workspaces.
这可能也适用于新的/不同的工作空间。
Note well: For the demo project/workspace, displayed within the screenshot, this has already been done and EclipseLink (2.5.2) was selected and downloaded previously. 注意: 对于屏幕截图中显示的演示项目/工作区,这已经完成,之前已选择并下载了EclipseLink(2.5.2)。 It's up to you to configure the persistence provider of your choice depending on your environment.
您可以根据自己的环境配置所选的持久性提供程序。
Finally, click on 'Apply and Close' to finish the basic JPA setup (step 3). 最后,单击“应用并关闭”以完成基本的JPA设置(步骤3)。 Afterwards, you have the necessary tooling to auto-generate entities from existing database tables, as seen in the next screenshot:
之后,您可以使用必要的工具从现有数据库表中自动生成实体,如下一个屏幕截图所示:
Actually, this only works with a working DB configuration, ie (local) database connection. 实际上,这仅适用于工作数据库配置,即(本地)数据库连接。 This can also be configured in the moment you setup the JPA provider and related tooling options, such as JDBC URL and JDBC driver jar file.
这也可以在您设置JPA提供程序和相关工具选项时配置,例如JDBC URL和JDBC驱动程序jar文件。
Hope it helps. 希望能帮助到你。
For documentation purposes: 出于文档目的:
Eclipse Java EE IDE for Web Developers.
Version: Oxygen Release (4.7.0)
Build id: 20170620-1800
Create a driver to connect to a specific database.创建驱动程序以连接到特定数据库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.