DataNucleus JPA plugin包含了一个注解处理器,当我们在编译实体类时,可以利用它生成静态元模型类(static metamodel classes)。使用这个插件需要JDK1.6及以上的版本。具体使用方法:
1.传参数给编译器
传以下命令行参数给编译器,就可以使用DataNucleus JPA plugin的注解处理器生成静态元模型类
-processor org.datanucleus.jpa.JPACriteriaProcessor
2.在maven中使用
在pom文件中包含以下内容,然后在maven构建时就会生成静态元模型的源码,并对它们进行编译
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<processor>org.datanucleus.jpa.JPACriteriaProcessor</processor>
</compilerArguments>
</configuration>
</plugin>