Netbeans 中的 JPA 2.0 元模型?
我读到,自版本 6.9 以来,Netbeans 包含了注释处理 支持,这是一项功能例如,需要生成 JPA 2.0 实体的元模型。
但是,我找不到任何示例或文档来准确说明如何执行此操作。你们有人成功了吗?
I've read that since version 6.9, Netbeans includes annotation processing support, a feature needed, for instance, to generate JPA 2.0 entities' metamodels.
However, I couldn't find any examples or documentation that shows exactly how to do it. Have any of you guys succeed on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我没有在 NetBeans 6.9 中尝试此功能,但根据 发行说明 (以及 Bug 178108),我的理解是,如果您正在使用 EclipseLink(并且如果将 eclipselink-jpa-modelgen.jar 添加到类路径):
对于其他持久性提供程序,您是否确实尝试添加其元模型生成器 JAR 并按照您提供的链接的第一部分和第二部分中的建议声明注释处理器?
相关问题
I didn't experiment this feature in NetBeans 6.9 but according to the release notes (and to Bug 178108), my understanding is that this is supposed to work out of the box if you are using EclipseLink (and if you add
eclipselink-jpa-modelgen.jar
to the classpath):For other persistence providers, did you actually try to add their metamodel generator JAR and to declare the annotation processor as suggested in part I and part II of the link you provided?
Related question
maven 编译器插件与注释处理器存在问题。使用 Maven 并不简单,有时会失败。不仅适用于 JPA,还适用于 netbeans 自己的注释和生成代码的处理器。即使没有遇到任何问题,您可能需要配置编译器插件才能与 ANN 处理器一起使用。请确保使用最新和最好的 mcp,其中修复了一些问题。
http://jira.codehaus.org/browse/MCOMPILER-122
http://jira.codehaus.org/browse/MCOMPILER-97
http://jira.codehaus.org/browse/MCOMPILER-71
http://jira.codehaus.org/browse/MCOMPILER-66
maven compiler plugin has problems with annotation processors. it's not straightforward to do with maven ans sometimes it fails. Applies not only to the JPA but also to netbeans' own annotations and processors that generate code. Even if not hit by any of the issues you might need to configure the compiler plugin to work with ann processors.. make sure to use the latest and greatest of m-c-p, some issues were fixed there.
http://jira.codehaus.org/browse/MCOMPILER-122
http://jira.codehaus.org/browse/MCOMPILER-97
http://jira.codehaus.org/browse/MCOMPILER-71
http://jira.codehaus.org/browse/MCOMPILER-66
Milos 是正确的 - 使用最新的 Maven 编译器插件,以及最新的 EclipseLink。另外,
eclipselink-jpa-modelgen.jar
文件必须位于您的依赖项中。设置项目的最简单方法是从 http: 下载最新的 NetBeans 6.10 夜间版本: //bits.netbeans.org/netbeans/trunk/nightly/ 并在此构建中创建项目 - 一切都应该运行良好。然后您可以在 NetBeans 6.9.1 中继续编辑该项目。
Milos is correct - use the latest Maven compiler plugin, and also the latest EclipseLink. Plus, the
eclipselink-jpa-modelgen.jar
file must be in your dependencies.The easiest way to set up the project is to download the latest nightly build of NetBeans 6.10 from http://bits.netbeans.org/netbeans/trunk/nightly/ and create the project in this build - everything should work well. Then you can continue editing this project in NetBeans 6.9.1.