Add QueryDSL Config
This commit is contained in:
23
build.gradle
23
build.gradle
@@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.6.2'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
|
||||
id 'java'
|
||||
}
|
||||
|
||||
@@ -37,6 +38,9 @@ dependencies {
|
||||
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
|
||||
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
|
||||
|
||||
implementation group: 'com.querydsl', name: 'querydsl-apt', version: '5.0.0'
|
||||
implementation group: 'com.querydsl', name: 'querydsl-jpa', version: '5.0.0'
|
||||
|
||||
implementation 'io.springfox:springfox-boot-starter:3.0.0'
|
||||
implementation 'io.springfox:springfox-swagger-ui:3.0.0'
|
||||
}
|
||||
@@ -44,3 +48,22 @@ dependencies {
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
def querydslDir = "$buildDir/generated/querydsl"
|
||||
|
||||
querydsl {
|
||||
jpa = true
|
||||
querydslSourcesDir = querydslDir
|
||||
}
|
||||
sourceSets {
|
||||
main.java.srcDir querydslDir
|
||||
}
|
||||
compileQuerydsl{
|
||||
options.annotationProcessorPath = configurations.querydsl
|
||||
}
|
||||
configurations {
|
||||
compileOnly {
|
||||
extendsFrom annotationProcessor
|
||||
}
|
||||
querydsl.extendsFrom compileClasspath
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mangkyu.employment.interview.config.querydsl;
|
||||
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
@Component
|
||||
public class QueryDslConfig {
|
||||
|
||||
@Bean
|
||||
public JPAQueryFactory jpaQueryFactory(final EntityManager em) {
|
||||
return new JPAQueryFactory(em);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user