在进行一次编译的时候,提示下面的错误信息:
??java: java.lang.ClassNotFoundException: org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor??
??
??
问题和解决
如果你对 Hibernate 的元数据还是不非常了解的话,请参考文章:??JPA 的 Metamodel??中的内容。
有关元数据生成器中的内容,请参看官方的:??JPA Static Metamodel Generator??
这里有几种使用方法:
我们使用了第一种的 Maven 配置方法:
<plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> <compilerArguments> <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> </compilerArguments> </configuration></plugin>
??
??
在我们的项目中和 lombok 的插件编译方法冲突了。
??
??
需要将上面的配置方法通过 ??annotationProcessorPaths??来进行配置。
修改后的配置如下:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven-compiler-plugin.version}</version> <configuration> <release>${java.version}</release> <annotationProcessorPaths> <path> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>5.4.33.Final</version> </path> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.24</version> </path> </annotationProcessorPaths> </configuration> </plugin>
然后再次编译和运行项目,上面的错误就解决了。
??
??
通常官方文档需要认真参考下。
??https://www.ossez.com/t/hibernate-metamodel/14038??
所有欺骗中,自欺是最为严重的