빡코

[스프링 데이터 JPA] 기초 설정 본문

Java/JPA

[스프링 데이터 JPA] 기초 설정

chris.djang 2023. 5. 10. 16:11

기초설정 

> Preferences Build, Execution, Deployment Build Tools 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 확인

 

 

gradel 의존관계 보기 

./gradlew dependencies --configuration compileClasspath

 

H2 database 설정 

https://www.h2database.com/html/main.html  

Spring boot 와 H2 database dependency 버전 맞추기

https://docs.spring.io/spring-boot/docs/2.5.14/reference/html/dependency-versions.html#appendix.dependency-versions

Database 추가하기 

C:\Users 경로에 db 생성 확인 

이후 접속 방법 

스프링 데이터 설정 파일 만들기 

application.yml

spring:
  datasource:
    url: jdbc:h2:tcp://localhost/~/이름
    username: 
    password:
    driver-class-name: org.h2.Driver

  jpa:
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        # show_sql: true
        format_sql: true

logging.level:
  org.hibernate.SQL: debug
  # org.hibernate.type: trace