Home Querydsl 기본 세팅
Post
Cancel

Querydsl 기본 세팅

Querydsl 기본 세팅

1️⃣ build.gradle에서 세팅

1
2
3
4
5
buildscript {
	ext {
		queryDslVersion = "4.4.0"
	}
}
1
2
3
4
5
implementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
annotationProcessor(
		"javax.persistence:javax.persistence-api",
		"javax.annotation:javax.annotation-api",
		"com.querydsl:querydsl-apt:${queryDslVersion}:jpa")
1
2
3
4
5
6
7
sourceSets {
	main {
		java {
			srcDirs = ["$projectDir/src/main/java", "$projectDir/build/generated"]
		}
	}
}

2️⃣ JpaFactory 설정

1
2
3
4
5
6
7
8
9
10
11
12
@Configuration
public class QuerydslConfig {

	@PersistenceContext
	private EntityManager entityManager;

	@Bean
	public JPAQueryFactory jpaQueryFactory() {
		return new JPAQueryFactory(entityManager);
	}

}
This post is licensed under CC BY 4.0 by the author.