queryDSL with gradle 5 & Spring Boot 2.7.x

By | 2023년 1월 7일
Table of Contents

queryDSL with gradle 5 & Spring Boot 2.7.x

간단히 build.gradle 만 설정해 주면 에러없이 사용할 수 있습니다.

개발환경

  • Spring Boot 2.7.x
  • Gradle 5.6.4

build.gradle

buildscript {
    ext {
        querydslVersion = "5.0.0"
    }
}

plugins {
    id 'org.springframework.boot' version '2.7.5'
    id 'io.spring.dependency-management' version '1.0.15.RELEASE'
    id 'java'
    id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
}

group = 'kr.pe.skyer9'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.mariadb.jdbc:mariadb-java-client'

    implementation "com.querydsl:querydsl-jpa:${querydslVersion}"
    annotationProcessor "com.querydsl:querydsl-apt:${querydslVersion}"

    implementation 'org.springframework.cloud:spring-cloud-openfeign-core:3.1.5'
    implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:3.1.5'
    implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.0'

    implementation 'org.mapstruct:mapstruct:1.5.3.Final'
    compileOnly 'org.projectlombok:lombok'
    compileOnly 'org.projectlombok:lombok-mapstruct-binding:0.2.0'
    annotationProcessor 'org.projectlombok:lombok'
    annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'

    implementation 'io.springfox:springfox-boot-starter:3.0.0'
    implementation 'io.springfox:springfox-swagger-ui:3.0.0'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

def querydslDir = "$buildDir/generated/querydsl"
querydsl {
    jpa = true
    querydslSourcesDir = querydslDir
}
sourceSets {
    main.java.srcDir querydslDir
}
configurations {
    querydsl.extendsFrom compileClasspath
}
compileQuerydsl {
    options.annotationProcessorPath = configurations.querydsl
}

답글 남기기