我使用gradle,springBoot,querydsl和mongodb。按照这篇文章添加下一个等级设置
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "gradle.plugin.com.ewerk.gradle.plugins:querydsl-plugin:1.0.9"
}
}
apply plugin: 'com.ewerk.gradle.plugins.querydsl'
sourceSets {
main {
java {
srcDir "$buildDir/generated/source/app/main"
}
}
}
dependencies {
compile "com.querydsl:querydsl-mongodb:4.1.4"
compileOnly "com.querydsl:querydsl-apt:4.1.4"
}
querydsl {
springDataMongo = true
querydslSourcesDir = "$buildDir/generated/source/app/main"
}
当我使用gradle bootRun
启动项目时,它工作得很好,但是当我只是使用gradle clean build
时,它在编译querydsl时失败了。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileQuerydslJava'.
> Compilation failed with exit code 1; see the compiler error output for details.
/Volumes/DATA/notification-service/app/build/generated/source/app/main/net/platform/notification/domain/impl/entity/QNotification.java:76: error: cannot find symbol
public QNotification(Path<? extends Notification> path) {
^
symbol: class Path
location: class QNotification
/Volumes/DATA/notification-service/app/build/generated/source/app/main/net/platform/notification/domain/impl/entity/QNotification.java:76: error: cannot find symbol
public QNotification(Path<? extends Notification> path) {
^
symbol: class Notification
location: class QNotification
/Volumes/DATA/notification-service/app/build/generated/source/app/main/net/platform/notification/domain/impl/entity/QNotification.java:80: error: cannot find symbol
public QNotification(PathMetadata metadata) {
^
symbol: class PathMetadata
location: class QNotification
/Volumes/DATA/notification-service/app/build/generated/source/app/main/net/platform/notification/domain/impl/entity/QNotification.java:5: error: package com.querydsl.core.types.dsl does not exist
import com.querydsl.core.types.dsl.*;
^
为什么它在构建过程中失败,并且在bootRun之后运行良好?
发布于 2018-02-26 20:17:34
这个问题出现在pmd插件中。
我将compileQuerydslJava
任务排除在构建./gradlew clean build -x compileQuerydslJava
中,并得到了下一个错误
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:pmdQuerydsl'.
> 46 PMD rule violations were found. See the report at: file:///Volumes/DATA/notification-service/app/build/reports/pmd/querydsl.html
因此,我为pmd插件指定了源代码集。
pmd {
sourceSets = [sourceSets.main]
}
现在效果很好。
https://stackoverflow.com/questions/48988083
复制相似问题