2016-07-13 4 views
5

Grale 2.3 및 QueryDSL 4.1.3을 사용하는 IntelliJ 15의 Spring-boot 1.4 프로젝트는 내 실체가 Querydsl에서 Q 클래스로 빌드되지 않기 때문에 빌드되지 않습니다. 내 단위 테스트를 실행할 때QueryDSL 및 Gradle이 포함 된 IntelliJ 15

buildscript { 
    ext { 
     springBootVersion = '1.4.0.BUILD-SNAPSHOT' 
     querydslVersion = '4.1.3' 
    } 
    repositories { 
     mavenCentral() 
     maven { url "https://repo.spring.io/snapshot" } 
     maven { url "https://repo.spring.io/milestone" } 
     maven {url "https://plugins.gradle.org/m2/"} 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
     classpath "gradle.plugin.com.ewerk.gradle.plugins:querydsl-plugin:1.0.7" 
    } 
} 

apply plugin: 'java' 
apply plugin: 'idea' 
apply plugin: 'eclipse' 
apply plugin: 'spring-boot' 
apply plugin: 'jacoco' 
apply plugin: 'groovy' 
apply plugin: "com.ewerk.gradle.plugins.querydsl" 

jar { 
    baseName = 'billing' 
    version = '0.0.1-SNAPSHOT' 
} 

sourceCompatibility = 1.8 
targetCompatibility = 1.8 

repositories { 
    mavenCentral() 
    jcenter() 
    maven { url "https://repo.spring.io/snapshot" } 
    maven { url "https://repo.spring.io/milestone" } 
    maven { url "https://repo.spring.io/libs-snapshot" } 
    maven { url "https://repo.spring.io/libs-snapshot"} 
    maven {url "https://plugins.gradle.org/m2/"} 

} 

dependencies { 
    compile('org.springframework.boot:spring-boot-starter-data-jpa') 
    compile('org.springframework.boot:spring-boot-starter-security') 
    compile('org.springframework.boot:spring-boot-starter-web') 
    compile "com.querydsl:querydsl-root:$querydslVersion" 
    compile "com.querydsl:querydsl-jpa:$querydslVersion" 
    compile "com.querydsl:querydsl-apt:$querydslVersion:jpa" 

    compile 'org.codehaus.groovy:groovy-all:2.4.1' 
    compile fileTree(dir: "libs/qbo-sdk-2.5.0", include: "*.jar") 

    testCompile('org.springframework.boot:spring-boot-starter-test') 
    testCompile('org.spockframework:spock-core:1.0-groovy-2.4') { 
     exclude group: 'org.codehaus.groovy', module: 'groovy-all' 
    } 

    testCompile('org.spockframework:spock-spring:1.0-groovy-2.4') { 
     exclude group: 'org.spockframework', module: 'spock-core' 
    } 
    testCompile("junit:junit") 

} 

sourceSets { 
    main { 
     output.resourcesDir = output.classesDir 
    } 
    generated { 
     java { 
      srcDirs = ['src/main/generated'] 
     } 
    } 
} 

querydsl { 
    library = 'com.mysema.querydsl:querydsl-apt' 
    querydslDefault = true 
} 


test { 
    reports.junitXml.destination = file('build/test-results/folder') 
} 

jacoco { 
    toolVersion = "0.7.0.201403182114" 
} 

jacocoTestReport { 
    group = "Reporting" 
    description = "Generate Jacoco coverage reports after running tests." 
} 

configurations { 
    querydslapt 
} 

task wrapper(type: Wrapper) { 
    gradleVersion = '2.3' 
} 

idea { 
    module { 
     sourceDirs += file('generated/') 
     generatedSourceDirs += file('generated/') 
    } 
} 

나는 오류 얻을 :

Caused by: java.lang.ClassNotFoundException: com.company.billing.customer.QCustomer 

을 내가 "Gradle을 정리 빌드를"실행할 때 내가 얻을 : 이 com.mysema를 찾을 수 없습니다 나는 다음 있습니다. querydsl : querydsl-apt :.

Searched in the following locations: https://repo1.maven.org/maven2/com/mysema/querydsl/querydsl-apt//querydsl-apt-.pom https://repo1.maven.org/maven2/com/mysema/querydsl/querydsl-apt//querydsl-apt-.jar https://jcenter.bintray.com/com/mysema/querydsl/querydsl-apt//querydsl-apt-.pom https://jcenter.bintray.com/com/mysema/querydsl/querydsl-apt//querydsl-apt-.jar https://repo.spring.io/snapshot/com/mysema/querydsl/querydsl-apt//querydsl-apt-.pom https://repo.spring.io/snapshot/com/mysema/querydsl/querydsl-apt//querydsl-apt-.jar https://repo.spring.io/milestone/com/mysema/querydsl/querydsl-apt//querydsl-apt-.pom https://repo.spring.io/milestone/com/mysema/querydsl/querydsl-apt//querydsl-apt-.jar https://repo.spring.io/libs-snapshot/com/mysema/querydsl/querydsl-apt//querydsl-apt-.pom https://repo.spring.io/libs-snapshot/com/mysema/querydsl/querydsl-apt//querydsl-apt-.jar

내가 QueryDsl 3 & 4 사이에 일부 패키지 리팩토링을했다 실현,하지만 내 종속성을 찾을 수없는 것처럼 그들은 분명히 여기에 비록 보이는이 :

https://mvnrepository.com/artifact/com.querydsl/querydsl-jpa/4.1.3는 적어도, 내 전류 왜 내 빌드가 실패하는지에 대한 이론. 누구든지 최신 스프링, gradle, querydsl을 사용 했습니까?

업데이트 : ewerk 플러그인을 제거하고 모든 빌드가 올바르게 완료되도록 build.gradle 파일을 단순화했습니다.

buildscript { 
    ext { 
     springBootVersion = '1.4.0.BUILD-SNAPSHOT' 
     querydslVersion = '4.1.3' 
    } 
    repositories { 
     mavenCentral() 
     maven { url "https://repo.spring.io/snapshot" } 
     maven { url "https://repo.spring.io/milestone" } 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
    } 
} 

apply plugin: 'java' 
apply plugin: 'idea' 
apply plugin: 'eclipse' 
apply plugin: 'spring-boot' 
apply plugin: 'jacoco' 
apply plugin: 'groovy' 

jar { 
    baseName = 'billing' 
    version = '0.0.1-SNAPSHOT' 
} 

sourceCompatibility = 1.8 
targetCompatibility = 1.8 

repositories { 
    mavenCentral() 
    jcenter() 
    maven { url "https://repo.spring.io/snapshot" } 
    maven { url "https://repo.spring.io/milestone" } 
    maven { url "https://repo.spring.io/libs-snapshot" } 
    maven { url "https://repo.spring.io/libs-snapshot"} 
    maven {url "https://plugins.gradle.org/m2/"} 
} 

dependencies { 
    compile('org.springframework.boot:spring-boot-starter-data-jpa') 
    compile('org.springframework.boot:spring-boot-starter-security') 
    compile('org.springframework.boot:spring-boot-starter-web') 
    compile "com.querydsl:querydsl-root:$querydslVersion" 
    compile "com.querydsl:querydsl-jpa:$querydslVersion" 
    compile "com.querydsl:querydsl-apt:$querydslVersion:jpa" 

    compile 'org.codehaus.groovy:groovy-all:2.4.1' 
    compile fileTree(dir: "libs/qbo-sdk-2.5.0", include: "*.jar") 

    testCompile('org.springframework.boot:spring-boot-starter-test') 
    testCompile('org.spockframework:spock-core:1.0-groovy-2.4') { 
     exclude group: 'org.codehaus.groovy', module: 'groovy-all' 
    } 

    testCompile('org.spockframework:spock-spring:1.0-groovy-2.4') { 
     exclude group: 'org.spockframework', module: 'spock-core' 
    } 
    testCompile("junit:junit") 
} 

test { 
    reports.junitXml.destination = file('build/test-results/folder') 
} 

jacoco { 
    toolVersion = "0.7.0.201403182114" 
} 

jacocoTestReport { 
    group = "Reporting" 
    description = "Generate Jacoco coverage reports after running tests." 
} 

task wrapper(type: Wrapper) { 
    gradleVersion = '2.3' 
} 

idea { 
    module { 
     sourceDirs += file('generated/') 
     generatedSourceDirs += file('generated/') 
    } 
} 

답변

7

Q 클래스가 Gradle 출력에서 ​​생성되는 것을 보시겠습니까? 오류가 발생하여 이미 생성해야하는 시점을 이미 지나친 것처럼 보입니다.

내가 문제는 JPAAnnotationProcessor을 구성하지 않는다고 생각합니다. 이것은 당신의 querydsl-apt 의존성에 jpa를 추가함으로써 gradle에서 편리함으로 수행됩니다. Maven에서는 manually 플러그인을 적용합니다.

나는 querydsl과 관련된 내 build.gradle 아래에 있습니다.

idea { 
    module { 
     sourceDirs += file('generated/') 
     generatedSourceDirs += file('generated/') 
    } 
} 
[...] 
compile "com.querydsl:querydsl-root:$querydslVersion" 
compile "com.querydsl:querydsl-jpa:$querydslVersion" 
compile "com.querydsl:querydsl-apt:$querydslVersion:jpa 

아이디어 블록은 IDEA에서 생성 된 소스 디렉토리를 자동으로 구성하기 때문에 IDE에서 올바르게 빌드됩니다.

편집 :

JPAAnnotationProcessor 출력은 다음과 같다.

Note: Running JPAAnnotationProcessor 
Note: Serializing Supertypes 
Note: Generating com.myclass.example.QMappedSuperClass for [com.myclass.example.MappedSuperClass] 
Note: Serializing Entity types 
Note: Generating com.myclass.example.QMyClass for [com.myclass.example.MyClass] 

편집 :

은 내가 ewerk 플러그인에 익숙하지 않은, 그래서 나는 보았다. JPAAnnotationProcessor를 활성화하려고합니다. 문서 here에 대한 JPA 플래그를 기본값으로 false로 설정해야 할 수도 있습니다.

종속성 문제와 관련하여 주석 스레드를 참조하십시오.

build.gradle.kts

plugins { 
    [...] 
    id("org.jetbrains.kotlin.kapt") version kotlinVersion 
} 

dependencies { 
    [...] 
    compile("com.querydsl:querydsl-core:$queryDslVersion") 
    compile("com.querydsl:querydsl-jpa:$queryDslVersion") 
    kapt("com.querydsl:querydsl-apt:$queryDslVersion:jpa") 
} 

주 당신이 때까지 Gradle을 자바 (8)을 사용해야 할 수도 있습니다 : 사람이 코 틀린 여기에서 Gradle을의 코 틀린의 DSL이 작업을 수행하고자하는 경우

+0

변경 사항을 내 gradble 파일에 추가하기 전이나 생성 된 클래스가 표시되지 않지만'com.mysema.querydsl : querydsl-apt :를 찾을 수 없습니다. '와 같은 오류가 발생합니다. 다음 위치에서 검색 : ....' – sonoerin

+0

죄송합니다. 당신의 의존성 오류를 놓쳤습니다. 이전 com.mysema 버전을 해결하려는 이유가 확실하지 않습니다. gradlew 종속성을 실행하고 종속성 트리에서 찾을 수 있습니까? – JudgingNotJudging

+0

나는 최신 Query DSL을 사용하고 있다고 생각 하나? 필자가 프로젝트를 설정하는 중 QueryData의 명시 적 사용은'com.mysema.query.types.Predicate'입니다. gradlew 종속성을 실행할 때 빌드 실패 'ould가'detachedConfiguration5 '구성의 모든 종속성을 해결하지 못합니다. > com.mysema.querydsl을 찾을 수 없습니다 : querydsl-apt' – sonoerin

0

는 그 설치와 함께 할 방법 Kapt 버그는 Kotlin 1.2.20에서 수정되었습니다.