JPA/queryDsl

queryDsl 모듈별 빌드

lovineff 2021. 3. 9. 17:39

build.gradle에 아래와 같이 작성한다.

'core' 공통 사용 모듈, 'admin', 'web' 모듈 프로젝트

def querydslProjects = [
        project(':core'),
        project(':admin'),
        project(':web')
]

configure(querydslProjects) {
    apply plugin: "io.spring.dependency-management"

    dependencies {
        compile("com.querydsl:querydsl-core")
        compile("com.querydsl:querydsl-jpa")

        annotationProcessor("com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jpa") // querydsl JPAAnnotationProcessor 사용 지정
        annotationProcessor("jakarta.persistence:jakarta.persistence-api") // java.lang.NoClassDefFoundError(javax.annotation.Entity) 발생 대응
        annotationProcessor("jakarta.annotation:jakarta.annotation-api") // java.lang.NoClassDefFoundError (javax.annotation.Generated) 발생 대응
    }

    // clean 태스크와 cleanGeneatedDir 태스크 중 취향에 따라서 선택하세요.
    /** clean 태스크 실행시 QClass 삭제 */
    clean {
        delete file('src/main/generated') // 인텔리제이 Annotation processor 생성물 생성위치
    }

    /**
     * 인텔리제이 Annotation processor 에 생성되는 'src/main/generated' 디렉터리 삭제
     */
    task cleanGeneatedDir(type: Delete) { // 인텔리제이 annotation processor 가 생성한 Q클래스가 clean 태스크로 삭제되는 게 불편하다면 둘 중에 하나를 선택
        delete file('src/main/generated')
    }
}

 

모듈 프로젝트내 공통 모듈 빌드 처리

각 모듈 프로젝트내에 build.gradle 파일을 생성하여 공통으로 사용하고자 하는 모듈을 입력한다.

dependencies {
    compile project(':core')
}

'JPA > queryDsl' 카테고리의 다른 글

QueryDsl between  (0) 2023.05.30
DB 함수 호출  (0) 2021.03.22
Filter 이름별 조건 설정 방법  (0) 2021.03.09
동적 쿼리 생성  (0) 2020.06.09
UPDATE, DELETE 문  (0) 2020.06.09