通过Maven生成
<build>
<plugins>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>3.3.3</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
eclipse开发工具生成
需要在 “Java Compiler” --> Enable “Annotation Processing”,然后在 “Factory Path” 中添加 hibernate-jpamodelgen-5.4.10.Final-sources.jar 和它的依赖包
网上绝大部份仅说添加hibernate-jpamodelgen-5.4.10.Final-sources.jar一个jar包,实际是行不通的,因为该jar包有依赖关系。
依赖Jar包可以在maven 仓库中下载