【问题标题】:Koitlin support for JPA static metamodelKotlin 对 JPA 静态元模型的支持
【发布时间】:2018-06-02 20:42:15
【问题描述】:

当我使用 Java JPA 创建 Entity 类时,会生成静态元模型。

如果我将我的实体转换为 Kotlin JPA,则不会生成静态元模型。

如何解决这个问题?

编辑

我使用 Gradle 作为构建工具。

【问题讨论】:

    标签: kotlin jpa-2.1 metamodel


    【解决方案1】:

    我必须使用kapt plugin

    我必须在我的 build.gradle 文件中添加以下行。

    kapt "org.hibernate:hibernate-jpamodelgen:${hibernate_version}"
    

    【讨论】:

      【解决方案2】:

      使用 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>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-05
        • 2015-05-26
        • 2014-07-16
        • 2012-12-13
        相关资源
        最近更新 更多