1. 프로젝트에서 아래와 같이 build.gradle 파일을 열어줍니다.

 

2. 아래와 같이 주석으로 1,2,3 설명된 부분을 추가해 줍니다. 

 

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

group = 'com.kabby'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
	mavenCentral()
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
	implementation 'org.springframework.boot:spring-boot-starter-security'
	implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'

  implementation 'com.querydsl:querydsl-jpa'

	compileOnly 'org.projectlombok:lombok'
	developmentOnly 'org.springframework.boot:spring-boot-devtools'
	runtimeOnly 'com.h2database:h2'
	runtimeOnly 'mysql:mysql-connector-java'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation('org.springframework.boot:spring-boot-starter-test') {
		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
	}
	testImplementation 'org.springframework.security:spring-security-test'
}

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

test {
	useJUnitPlatform()
}

3. build 후 실행을 시켜주면, 아래와 같이 Q-class 들이 생성 됩니다.

  • Entity을 생성 했다는 가정 입니다.

 

 

+ Recent posts