0

我正在将 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")
}

我建议它应该将 Q 类构建到build/generated/source/kapt/main. 任何想法为什么它不起作用?
还尝试用@QueryEntity注释来注释我的实体。也不能正常工作

4

1 回答 1

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")
于 2021-07-29T21:03:43.517 回答