h2 데이터베이스 Springboot에서 설정하는 방법

4724 단어 H2SpringbootH2

build.gradle 설정

runtimeOnly 'com.h2database:h2'

application yml 설정

spring:
  h2:
    console:
      enabled: true

  jpa:
    database-platform: org.hibernate.dialect.H2Dialect
    open-in-view: false
    hibernate:
      ddl-auto: create
      properties:
        hibernate:
          show_sql: true
          format_sql: true
  • 초기 설정
spring:
  h2:
    console:
      enabled: true
  • /h2-console 디폴트 설정
  datasource:
    url: jdbc:h2:mem:testdb
    driver-class-name: org.h2.Driver
    hikari:
      username: sa
      password:
  • h2 - jpa 연결 설정
  jpa:
    database-platform: org.hibernate.dialect.H2Dialect
    open-in-view: false
    hibernate:
      ddl-auto: create
      properties:
        hibernate:
          show_sql: true
          format_sql: true

프로젝트를 실행시 Run console에 JDBC URL이 나오게 되있다.

H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:26b18340-687a-410e-9653-c8c5acf95356'

그리고
http://localhost:8080/h2-console 접속
Run console에 나온 JDBC URL을 입력한다.

드디어 h2 웹콘솔로 들어가진다.

좋은 웹페이지 즐겨찾기