📒 [실전! 스프링 부트와 JPA 활용 - 김영한] 학습 후 정리자료입니다.
📒 Gradle 공식 홈페이지에서 참고한 내용입니다.
plugins {
id 'org.springframework.boot' version '2.7.5'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}
group = 'jpabook'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.6'
implementation 'junit:junit:4.13.1'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
plugins {
id 'org.springframework.boot' version '2.7.5'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}
plugins
을 적용하면 plugins
이 프로젝트의 기능을 확장할 수 있습니다.Gradle
모델 확장logic
을 추가하는 대신 plugins
을 적용하면 많은 이점을 얻을 수 있습니다.High Performance : Gradle은 입력 또는 출력이 변경되어 실행해야 하는 작업만 실행하여 불필요한 작업을 방지합니다.
Extensibility : Gradle을 쉽게 확장하여 고유한 작업 유형을 제공하거나 모델을 빌드할 수도 있습니다.
Conventions : 적절한 플러그인을 적용하면 많은 프로젝트에서 슬림한 빌드 스크립트로 쉽게 끝낼 수 있습니다.
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
Configuration
는 아티팩트 및 해당 종속성 그룹을 나타냅니다.compileOnly
는 컴파일 전용 종속성 선언 역할을 합니다. extendsFrom
은 이 구성이 확장되는 구성의 이름입니다. 슈퍼 구성의 아티팩트도 이 구성에서 사용할 수 있습니다.Lombok
이 제공하는 어노테이션을 이용해서 작업을 처리하려면 Gradle에서는 AnnotationProcessor 라는 의존성 옵션을 사용해야합니다.AnnotationProcessor
의존성 옵션은 javac 명령어의 -processorpath 옵션으로 전달되는 라이브러리를 정의합니다.dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.6'
implementation 'junit:junit:4.13.1'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
dependencies
는 의존성 관리를 위한 영역입니다.