ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • #Spring Data JPA - 1 프로젝트 생성
    Spring Data JPA 2021. 3. 12. 17:01

    프로젝트 생성

    ·스프링 부트 스타터(https://start.spring.io/)

    ·사용 기능: web, jpa, h2, lombok

        · SpringBootVersion: 2.2.1

        · groupId: study

        · artifactId: data-jpa

     

    Gradle 전체 설정

    plugins {
    	id ‘org.springframework.boot’ version ‘2.2.1.RELEASE’
    	id ‘io.spring.dependency-management’ version ‘1.0.8.RELEASE’
    	id ‘java’
    }
    group = ‘study’
    version = ‘0.0.1-SNAPSHOT’
    sourceCompatibility = ‘1.8’
    configurations {
    	compileOnly {
    		extendsFrom annotationProcessor
    	}
    }
    repositories {
    	mavenCentral()
    }
    dependencies {
    	implementation ‘org.springframework.boot:spring-boot-starter-data-jpa’
    	implementation ‘org.springframework.boot:spring-boot-starter-web’
    	implementation ‘com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.7’
    	compileOnly ‘org.projectlombok:lombok’
    	runtimeOnly ‘com.h2database:h2’
    	annotationProcessor ‘org.projectlombok:lombok’
    	testImplementation(‘org.springframework.boot:spring-boot-starter-test’) {
    		exclude group: ‘org.junit.vintage’, module: ‘junit-vintage-engine’
    	}
    }
    test {
    	useJUnitPlatform()
    }

    참고: 최근 IntelliJ 버전은 Gradle로 실행을 하는 것이 기본 설정이다.

    이렇게 하면 실행속도가 느리다. 다음과 같이 변경하면 자바로 바로 실행하므로 좀 더 빨라진다.

     

     Preferences → Build, Execution, Deployment   Build Tool  s Gradle

     Build and run using: Gradle   IntelliJ IDEA

     Run tests using: Gradle   IntelliJ IDEA

     

     

    롬복 적용

    1. Preferences plugin lombok 검색 실행 (재시작)

    2. Preferences Annotation Processors 검색 Enable annotation processing 체크 (재시작)

    3. 임의의 테스트 클래스를 만들고 @Getter, @Setter 확인

     

     

     

     

    라이브러리 살펴보기

    gradle 의존관계 보기

    ./gradlew dependencies --configuration compileClasspath

    스프링 부트 라이브러리 살펴보기

    · spring-boot-starter-web

        · spring-boot-starter-tomcat: 톰캣 (웹서버)

        · spring-webmvc: 스프링 웹 MVC

    · spring-boot-starter-data-jpa

        · spring-boot-starter-aop

        · spring-boot-starter-jdbc

            · HikariCP 커넥션 풀 (부트 2.0 기본)

        · hibernate + JPA: 하이버네이트 + JPA

        · spring-data-jpa: 스프링 데이터 JPA

    · spring-boot-starter(공통): 스프링 부트 + 스프링 코어 + 로깅

        · spring-boot

            · spring-core

        · spring-boot-starter-logging l

            · ogback, slf4j

     

    테스트 라이브러리

    · spring-boot-starter-test

        · junit: 테스트 프레임워크, 스프링 부트 2.2부터 junit5( jupiter ) 사용

            · 과거 버전은 vintage

        · mockito: 목 라이브러리

        · assertj: 테스트 코드를 좀 더 편하게 작성하게 도와주는 라이브러리

             · https://joel-costigliola.github.io/assertj/index.html

        · spring-test: 스프링 통합 테스트 지원

    · 핵심 라이브러리

        · 스프링 MVC

        · 스프링 ORM

        · JPA, 하이버네이트

        · 스프링 데이터 JPA

    · 기타 라이브러리

        · H2 데이터베이스 클라이언트

        · 커넥션 풀: 부트 기본은 HikariCP

        · 로깅 SLF4J & LogBack

        · 테스트

     

    댓글

Designed by Tistory.