【发布时间】:2018-06-02 20:42:15
【问题描述】:
当我使用 Java JPA 创建 Entity 类时,会生成静态元模型。
如果我将我的实体转换为 Kotlin JPA,则不会生成静态元模型。
如何解决这个问题?
编辑
我使用 Gradle 作为构建工具。
【问题讨论】:
当我使用 Java JPA 创建 Entity 类时,会生成静态元模型。
如果我将我的实体转换为 Kotlin JPA,则不会生成静态元模型。
如何解决这个问题?
编辑
我使用 Gradle 作为构建工具。
【问题讨论】:
我必须使用kapt plugin。
我必须在我的 build.gradle 文件中添加以下行。
kapt "org.hibernate:hibernate-jpamodelgen:${hibernate_version}"
【讨论】:
使用 Maven 时,将以下 sn -p 添加到 <executions> 的 kotlin-maven-plugin 中。
<execution>
<id>kapt</id>
<goals>
<goal>kapt</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>src/main/kotlin</sourceDir>
</sourceDirs>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.3.2.Final</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</execution>
【讨论】: