【问题标题】:Kotlin QueryDsl not generating Q classesKotlin QueryDsl 不生成 Q 类
【发布时间】:2021-07-31 18:41:09
【问题描述】:

我正在将 kts gradle 与 koltin 一起使用。但是,当我尝试添加 QueryDsl 时,它不是来自我的 JPA 实体的生成 Q 类。

我的 build.gradle.kts 看起来像:

plugins {
  id("org.springframework.boot") version "2.3.1.RELEASE"
  id("io.spring.dependency-management") version "1.0.9.RELEASE"
  kotlin("jvm") version "1.3.72"
  kotlin("plugin.spring") version "1.3.72"
  kotlin("plugin.jpa") version "1.3.72"
  kotlin("kapt") version "1.4.0"
  kotlin("plugin.allopen") version "1.4.10"
} 

dependencies {
  // some spring boot dependencies here...
  implementation("com.querydsl:querydsl-jpa:4.2.1")
  kapt("com.querydsl:querydsl-apt:4.2.1:general")
}

kapt {
 annotationProcessor("org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor")
}

我建议它应该为build/generated/source/kapt/main 构建Q 类。任何想法为什么它不起作用?
还尝试使用 @QueryEntity 注释来注释我的实体。效果不好

【问题讨论】:

  • kotlin("jvm")kotlin("kapt") 有不同的版本。如果你统一所有 gradle kotlin 插件的版本,它会工作吗?
  • 遇到同样的问题,你解决了吗?
  • @MartinSchüller 是的,发布了答案,希望对您有所帮助

标签: kotlin querydsl gradle-kotlin-dsl


【解决方案1】:

通过添加下一个配置解决问题

// quert dsl
implementation("com.querydsl:querydsl-jpa:4.2.1")
kapt("com.querydsl:querydsl-apt:4.2.2:jpa")
annotationProcessor(group = "com.querydsl", name = "querydsl-apt", classifier = "jpa")

我也删除了

annotationProcessor("org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-25
    • 2012-12-06
    • 1970-01-01
    • 2014-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-01
    相关资源
    最近更新 更多