Spring/Spring Data

로컬 인메모리 H2 데이터베이스 yaml 설정

제우제우 2024. 8. 19. 10:54

application.yaml 

spring:
  h2:
    console:
      enabled: true
      path: /h2-console
  datasource:
    url: jdbc:h2:mem:jeulog
    username: sa
    password:
    driver-class-name: org.h2.Driver

 

spring.h2.console.enabled

  • H2 데이터베이스의 웹 콘솔을 활성화
  • 웹 콘솔을 통해 브라우저에서 데이터베이스를 관리하고, SQL 쿼리를 실행 가능 

spring.h2.console.path

  • H2 콘솔에 접근할 수 있는 URL 경로를 지정
  • http://localhost:8080/h2-console로 접속

spring.datasource.url

  • jdbc:h2:mem : H2 데이터베이스를 인메모리 모드로 사용하겠다는 의미
  • jeulog : 데이터베이스 이름 

spring.datasource.driver-class-name

  • H2 데이터베이스를 사용하기 위한 JDBC 드라이버 클래스를 지정