eclipse 现有的 maven 项目添加 jpa 支持?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1960613/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:15:05  来源:igfitidea点击:

eclipse existing maven project add jpa support?

javaeclipsejpaeclipse-plugin

提问by cometta

how to add jpa support for existing maven project

如何为现有的 Maven 项目添加 jpa 支持

i tried

我试过

project-->configure--> convert to jpa project (there is no this option)

project-->configure--> 转换为jpa项目(没有这个选项)

but for my other projects, such option available... can comment?

但是对于我的其他项目,这样的选项可用......可以评论吗?

I already have existing mven project and i want to generate jpa entity from tables. no need to create new jpa project right?

我已经有现有的 mven 项目,我想从表中生成 jpa 实体。不需要创建新的 jpa 项目对吗?

采纳答案by Pascal Thivent

I'm not sure but I think that you need to setup your project to use the JPA Facet (right click on the project the Properties> Project Facetsand select Java Persistence). I don't know if m2eclipse can add this facet automatically.

我不确定,但我认为您需要设置您的项目以使用 JPA Facet(右键单击项目Properties> Project Facets并选择Java Persistence)。不知道m2eclipse能不能自动添加这个facet。

But actually, with the version of Eclipse I'm using, adding the JPA facet doesn't add any entry for JPA under Configurewhen I right click on a project. It adds a menu JPA Tools> Generate Entities from Tables...(and JPA Tools> Generate Tables from Entities...).

但实际上,对于我使用的 Eclipse 版本,当我右键单击一个项目时,添加 JPA 方面不会在配置下为 JPA 添加任何条目。它添加了一个菜单JPA Tools> Generate Entities from Tables...(和JPA Tools> Generate Tables from Entities...)。

回答by Roby Gamboa

Be sure to coordinate your Maven dependencies with the Eclipse JPA configuration. By default, Eclipse uses EclipseLink as its JPA implementation, which would require the use of a specific repository location and set of dependencies for the associated components in your project POM. If you choose to use EclipseLink rather than another JPA user library, ensure that the version numbers are consistent between the Eclipse and Maven configuration settings. More information on Eclipse and Maven/Eclipse configuration can be found at: http://www.eclipse.org/eclipselink/downloads/.

请确保将您的 Maven 依赖项与 Eclipse JPA 配置进行协调。默认情况下,Eclipse 使用 EclipseLink 作为其 JPA 实现,这需要使用特定的存储库位置和项目 POM 中关联组件的一组依赖项。如果您选择使用 EclipseLink 而不是其他 JPA 用户库,请确保 Eclipse 和 Maven 配置设置之间的版本号一致。有关 Eclipse 和 Maven/Eclipse 配置的更多信息,请访问:http: //www.eclipse.org/eclipselink/downloads/

Use the 'EclipseLink P2 Repository' info to set up your workbench EclipseLink version and libraries, and follow the 'EclipseLink Maven Repository' link to set up your project POM to match it.

使用“EclipseLink P2 Repository”信息设置您的工作台 EclipseLink 版本和库,并按照“EclipseLink Maven Repository”链接设置您的项目 POM 以匹配它。