test할 때 DB까지 왔다갔다하기 번거롭다면, 메모리를 사용하자. (DB를 꺼놔도 Test 실행가능)
1. H2 DB 메모리 모드사용
main>resources > application.yml 을 복사해
test > resources > application.yml에 붙이고 url만 변경하기(아래 참고)
//test > resources > application.yml 내용
spring:
datasource:
url: jdbc:h2:mem:test
username: sa
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
변경할 메모리 URL 주소찾기
H2접속 > Cheat Sheet
in-Memory 아래 주소 사용
jdbc:h2:mem:test
2. Spring boot의 메모리모드
application.yml에 따로 설정이 없다면 spring boot가 메모리 모드로 만들어줌.
//test > resources > applicaion.yml
logging.level:
org.hibernate.SQL: debug
org.hibernate.type: trace
'Spring boot' 카테고리의 다른 글
[spring boot] OSIV와 영속성 컨텍스트 (0) | 2021.12.08 |
---|---|
[spring boot] API 성능 최적화 (+ DTO 장점) (0) | 2021.12.03 |
[spring boot] 3차 정리 (프록시, 즉시 로딩, 지연 로딩) (0) | 2021.11.04 |
[spring boot] 2차 정리 (연관관계 매핑 기초, 다양한 연관관계 매핑, 고급 매핑) (0) | 2021.10.28 |
[spring boot] 1차 정리(jpa 시작, 영속성관리, 엔티티 매핑) (0) | 2021.10.28 |