H2 (내장 데이터베이스)

spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.url=jdbc:h2:~/local
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
jdbc:h2:mem:db_dev;MODE=MYSQL (메모리모드 방식)
C:\Users\사용자 경로에
local.mv.db 파일 생성


http://localhost:8080/h2-console 콘솔로 접속 확인

#build.gradle 의존성 추가
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
#JPA
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=create
SQL 문법을 H2Dialect로 사용하고, 테이블 생성 규칙 설정
#sql 로그 보기 위한 옵션
application.properites
spring.jpa.show-sql=true
#값 확인
logging.level.org.hibernate.orm.jdbc.bind=TRACE
ex) 2025-07-28 21:00:12 TRACE ... Binding parameter [1] as [VARCHAR] - [sbb]
#결과 확인
logging.level.org.hibernate.orm.jdbc.extract=TRACE
ex) 2025-07-28 21:00:12 TRACE ... extracted value ([name] : VARCHAR) - [hyojung]
#SQL 문을 콘솔에 출력
spring.jpa.show-sql=true
#줄바꿈과 들여쓰기를 적용
spring.jpa.properties.hibernate.format_sql=true
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=file:src/main/resources/templates/