plugins {
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
}
dependencise {
implementation 'com.querydsl:querydsl-jpa'
}
// querydsl 추가
def querydslDir = "$buildDir/generated/querydsl"
querydsl {
jpa = true
querydslSourcesDir = querydslDir
}
sourceSets {
main.java.srcDir querydslDir
}
configurations {
querydsl.extendsFrom compileClasspath
}
compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl
}
Reload gradle projects
QEntity를 생성하기 위한 Entity 클래스를 생성합니다
생성된 Entity를 QEntity로 생성하기 위해 other > compileQuerydsl을 실행합니다
build.gradle에 설정된 querydslDir 디렉토리에 QEntity 파일이 생성됩니다
Third-party 라이브러리와 Gradle 버전이 호환되지 않는 문제 발생
현재 사용중인 Gradle Version 7.3
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
위와 같이 최신 버전의 Gradle 사용 시 complieQuerydsl 에러가 발생하는 경우
querydsl-apt library 설정을 추가해 주시면 해결하실 수 있습니다
library = "com.querydsl:querydsl-apt"
querydsl-apt(APT based Source code generation for Querydsl querydsl : 소스코드로 변환해주는 라이브러리)
querydsl {
library = "com.querydsl:querydsl-apt"
jpa = true
querydslSourcesDir = querydslDir
}
buildDir/generated/querydsl 경로에
정상적으로 QEntity가 생성된 것을 확인하실 수 있습니다
(QEntity 파일이 생성된 것은 확인해야만 합니다)
Generated 되어진 소스는 세부 내용이 변경될 수 있어
Git에 포함되지 않도록 .gitignore 파일에 추가해주시거나
현재 설정된 경로처럼 기본적으로 ignore 되어지는
build 하위 경로에 QEntity가 생성되도록 설정을 해주시면 됩니다
JWT, AuthenticationManager, JwtAuthenticationProvider (0) | 2024.02.16 |
---|---|
JPA, H2 database 설정 (0) | 2021.12.12 |
Spring, Bean, IoC, DI 개념에 대한 정리 (0) | 2021.10.19 |
[JSP 연결] Spring Boot + Gradle + IntelliJ (0) | 2018.05.20 |
[개발환경] Spring Boot + Gradle + IntelliJ 프로젝트 생성하기 (0) | 2018.05.20 |
댓글 영역