在sbt中运行EclipseLink元模型生成器

在sbt中运行EclipseLink元模型生成器

本文介绍了在sbt中运行EclipseLink元模型生成器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用sbt,如何执行EclipseLink提供的注释处理器org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor,以便从我的实体类生成元模型?

Using sbt, what should I do to execute annotation processor org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor provided by EclipseLink in order to generate the metamodel from my entity classes?

推荐答案

对于不耐烦的人

  1. 克隆项目ssdemojpa

$ git clone http://github.com/frgomes/ssdemojpa

$ git clone http://github.com/frgomes/ssdemojpa

从SBT控制台输入以下命令:

Enter the commands below from the SBT console:


zap
reload
metamodel
compile
test

详细说明

项目ssdemojpa提供了有关如何将PlayFrameworkSecureSocial(用于OpenID/OAuth/OAuth2身份验证)和EclipseLink(作为JPA提供程序)集成的演示.该演示应用程序还提供了与Twitter4J的非常简单的集成,以便从Twitter检索趋势.

Detailed Description

Project ssdemojpa provides a demo about how PlayFramework can be integrated with SecureSocial (for OpenID/OAuth/OAuth2 authentication) and EclipseLink (as a JPA provider). The demo application also provides a very simple integration with Twitter4J in order to retrieve trends from Twitter.

SBT脚本: https://github.com/frgomes/ssdemojpa /blob/master/project/Build.scala

在上面引用的SBT构建脚本中,trait Metamodel负责定义任务metamodel,该任务处理JPA实体类并在实体类所在的同一目录中生成元模型.

In the SBT build script referenced above the trait Metamodel is responsible for defining task metamodel which processes the JPA entity classes and generates the metamodel in the same directory where your entity classes are located.

请注意,子模块models包含带注释的JPA实体类,并且必须使用Java8进行编译,因为DAO类(而不是实体类中)使用Java8语法.

Notice that the submodule models contains annotated JPA entity classes and must be compiled with Java8, since Java8 syntax is employed in DAO classes (but not in entity classes).

请注意,注释处理器不能识别Java7和Java8引入的功能,但是只要您不在实体类中使用Java7/Java8语法,就可以使用Java7或Java8来编译代码.您可以在其他类中使用Java7/Java8语法.同样:ssdemojpa需要Java8.

Notice that the annotation processor does not recognize features introduced by Java7 and Java8, but you can compile your code using Java7 or Java8 anyway, provided that you do not employ Java7/Java8 syntax in your entity classes. You can employ Java7/Java8 syntax in other classes. Again: ssdemojpa requires Java8.

如果您使用Java7或Java8编译代码,则注释处理器将发出警告,警告您,但无论如何,它将生成关联的元类,因为您的实体类必须遵循Java6语法.在这种情况下,警告消息是无关紧要的,只要您已经正确定义了实体类,一切都应该可以正常工作.

In case you compile your code with Java7 or Java8, the annotation processor will emit a warning complaining about that but it will generate the associated metaclasses anyway, since your entity classes necessarily obey with Java6 syntax. The warning message is irrelevant in this case and everything should work just fine, provided that you've defined your entity classes properly.

这篇关于在sbt中运行EclipseLink元模型生成器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 03:16