在Query DSL中找不到查询类。但Q类已经存在,Intellij已经确定

时间:2018-01-27 06:12:26

标签: spring-boot gradle intellij-idea querydsl

我正在尝试在我的项目中使用QDataTableRepository。这让我必须导入querydsl。

build.gradle

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'idea'

repositories {
    mavenCentral()
}


dependencies {
    compile("org.springframework.boot:spring-boot-devtools")
    compile('org.springframework.boot:spring-boot-starter')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.postgresql:postgresql:9.4.1212')
    compile('org.projectlombok:lombok:1.16.10')
    compile group: 'com.github.darrachequesne', name: 'spring-data-jpa-datatables', version: '3.1'
    compile group: 'com.querydsl', name: 'querydsl-jpa', version: '4.1.4'
    compile group: 'com.querydsl', name: 'querydsl-apt', version: '4.1.4'

    testCompile('org.springframework.boot:spring-boot-starter-test')

}

configurations {
    querydslapt
}

sourceSets {
    generated
}
sourceSets.generated.java.srcDirs = ['generated/']

task generateQueryDSL(type: JavaCompile, group: 'build', description: 'Generates the QueryDSL query types') {
    source = sourceSets.main.java
    classpath = configurations.compile + configurations.querydslapt
    options.compilerArgs = [
            "-proc:only",
            "-processor", "com.mysema.query.apt.jpa.JPAAnnotationProcessor"
    ]
    destinationDir = sourceSets.generated.java.srcDirs.iterator().next()
}

compileGeneratedJava {
    dependsOn generateQueryDSL
    classpath += sourceSets.main.runtimeClasspath
}

我还在Intellij中设置注释处理器。

Picture of Annotation Processor setting

我构建我的项目并构建成功。 QClass在里面生成。
这里

Structure

/**
 * QClient is a Querydsl query type for Client
 */
@Generated("com.mysema.query.codegen.EntitySerializer")
public class QClient extends EntityPathBase<Client> {

但是当我运行项目错误时。

Caused by: java.lang.IllegalArgumentException: Did not find a query class com.project.module.client.QClient for domain class om.project.module.client.Client!

我错过了配置吗?

0 个答案:

没有答案