编程语言
首页 > 编程语言> > java – 升级到Gradle 5后的Querydsl Annotation Processor问题

java – 升级到Gradle 5后的Querydsl Annotation Processor问题

作者:互联网

我有一个gradle脚本,它从Mongo带注释的实体生成querydsl类.它到目前为止工作,但升级到Gradle 5后我遇到了一个问题:

* What went wrong:
Execution failed for task ':myproject-common:compileQuerydsl'.
Annotation processor 'org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor' not found

请在下面找到我的gradle.build脚本.什么想法可能是错的?我读到Gradle 5中有一些变化,在编译期间默认情况下不使用注释处理器,并且应该添加annotationProcessor声明,但是当我将它添加到依赖项时,会发生相同的错误.

plugins {
    id 'org.springframework.boot' version '2.0.4.RELEASE'
    id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
}
repositories {
    mavenCentral()
}
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
jar {
    enabled = true
    baseName = 'myproject-common'
    version =  '0.0.1-SNAPSHOT'
}
// do no package commons into fat jar
bootJar {
    enabled = false
}
querydsl {
    library = 'com.querydsl:querydsl-apt:4.1.4'
    querydslSourcesDir = 'src/main/querydsl'
    springDataMongo = true
}
sourceCompatibility = 11.0
targetCompatibility = 11.0
sourceSets {
    main {
        java {
            srcDirs = ['src/main/java', 'src/main/querydsl']
        }
    }
}
dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.data:spring-data-mongodb")
    compile("org.springframework.boot:spring-boot-starter-data-rest")
    compile("org.springframework.boot:spring-boot-starter-security")
    compile("com.fasterxml.jackson.datatype:jackson-datatype-    jsr310:2.8.6")
    compile("com.google.guava:guava:23.0")
    compile("commons-io:commons-io:2.5")
    compile("org.aspectj:aspectjweaver:1.8.9")
    compile("org.apache.commons:commons-lang3:3.5")
    compile("commons-collections:commons-collections:3.2.2")
    compile("org.javamoney:moneta:1.1")
    compile("com.fizzed:rocker-runtime:1.2.0")
    compile("com.querydsl:querydsl-core:4.1.4")
    compile("com.querydsl:querydsl-mongodb:4.1.4")
    compile("com.querydsl:querydsl-apt:4.1.4")
    compile("com.codepoetics:protonpack:1.15")

    testCompile("org.springframework.boot:spring-boot-starter-test")
    testCompile("org.assertj:assertj-core:3.7.0")
}

解决方法:

我终于找到了解决方法. Querydsl缺乏与Gradle 5的兼容性在这里报告为一个错误:https://github.com/ewerk/gradle-plugins/issues/108

解决方法是添加到gradle脚本:

compileQuerydsl {
    options.annotationProcessorPath = configurations.querydsl
}

标签:querydsl,java,gradle
来源: https://codeday.me/bug/20190823/1697111.html