Back End/Spring Boot

Querydsl dependency 추가방법

DevHam94 2024. 4. 9. 17:29

build.gradle을 아래와같이 설정해준다. 

 

추가하는 코드중에 s라던지 오타가 있으면 에러가 나온다. (스프링 부트 3버전 기준) 

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.1.10'
    id 'io.spring.dependency-management' version '1.1.4'
    //querydsl 추가
//    id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
}

group = 'study'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    //Querydsl 추가
    implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
    annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
    annotationProcessor "jakarta.annotation:jakarta.annotation-api"
    annotationProcessor "jakarta.persistence:jakarta.persistence-api"

    implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.8'

    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'com.h2database:h2'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

//tasks.named('bootBuildImage') {
//    builder = 'paketobuildpacks/builder-jammy-base:latest'
//}
//
//tasks.named('test') {
//    useJUnitPlatform()
//}

//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 추가 끝