gpt4 book ai didi

java - 如何在 IntelliJ IDEA 中生成 JPA Hibernate Metamodel 类?

转载 作者:太空宇宙 更新时间:2023-11-04 09:17:30 25 4
gpt4 key购买 nike

我正在尝试在 IntelliJ idea 中使用 Hibernate 生成元模型类。我已经看过最旧的教程,但它们对我没有帮助。还有其他方法可以生成该文件吗?我发现有关 IntelliJ 中元模型支持的主题太旧了。也许我做错了什么。我会解释一下我在做什么。

我已经尝试过:

  • 在 IntelliJ 设置中启用处理:设置 > 构建、执行、部署 > 编译器 > 注释处理器 > [选中] 启用注释处理。

  • 将 maven-processor 放入 pom.xml 中。 (jpa.modelgen.CanonicalModelProcessor)

  • 重建项目。

我包含在 pom.xml 中的插件:

<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>1.3.5</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<outputDirectory>${project.build.directory}/generated-sources/metamodel</outputDirectory>
<compilerArguments>
-Aeclipselink.persistencexml=${project.basedir}/src/main/resources/META-INF/persistence.xml
</compilerArguments>
<processors>
<processor>org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>

最佳答案

将以下依赖项放入项目的 pom.xml 中。

<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-jpamodelgen -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.3.7.Final</version>
<scope>provided</scope>

</dependency>

然后使用模块/项目的构建路径上的..path_to_root_directory_of_module_of_entities/target/classes/目录。它将向项目运行时提供所有自动生成的静态模型类。

关于java - 如何在 IntelliJ IDEA 中生成 JPA Hibernate Metamodel 类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58794328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com