
컴터에 설치한 java가 11 버전이라 spring 2.x 를 사용.


build.gradle 파일에 query dsl 관련 내용 추가
plugin {
...
//querydsl 추가
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
}
dependencies {
...
//querydsl 추가
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
}
//querydsl 추가 끝

내 경우 에러가 뜸. 스프링 버전이랑 쿼리 dsl 버전이 안 맞아서 그런듯.


이후 compileQueryDsl 다시 해주면, 이처럼 QHello 라는 파일이 생김!!

이런것 gitignore 되어야 하는 빌드 파일임!! (query dsl 버전따라 달라질 수 있으니!)
첫 한번(생성시)은 파일 모드로 접근해야함.

이후에 tcp 모드로 접근 ㄱㄱ


yml 파일 따로 생성
spring:
datasource:
url: jdbc:h2:tcp://localhost/~/querydsl
username: sa
password:
driver-class-name: org.h2.Driver
jpa:
hibernate:
ddl-auto: create
properties:
hibernate:
# show_sql: true
format_sql: true
logging.level:
org.hibernate.SQL: debug
# org.hibernate.type: trace

쿼리로 나가는 값을 알고 싶을때는 외부 라이브러리를 설치해주면 됨.
(실무에서는 성능을 꼭 확인하길 바람)
// query log 남기기
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.8'