본문 바로가기

프로그래밍/Spring Boot

Spring Boot_H2 DB 초기 설정

반응형

H2 메모리 DB 초기 테이블 설정 및 초기 데이터 셋팅

1. 이클립스 마켓 플레이스 > sql 검색 > sql editor 1.4.0 설치

2. yml 파일 확인 및 추가 설정

 

yml 파일에 아래 코드 추가

sql:
    init:
      schema-locations:
      - classpath:db/table.sql
      data-locations:
      - classpath:db/data.sql

전체 코드

server:
  port: 8080
  servlet: 
    encoding:
      charset: utf-8
      force: true
      
spring:
  mvc:
    view:
      prefix: /WEB-INF/view/
      suffix: .jsp
  datasource:
    url: jdbc:h2:mem:testdb;MODE=MySQL
    driver-class-name: org.h2.Driver
    username: sa
    password:
  sql:
    init:
      schema-locations:
      - classpath:db/table.sql
      data-locations:
      - classpath:db/data.sql
    
  h2: 
    console: 
      enabled: true
  output:
    ansi: 
      enabled: always
반응형

'프로그래밍 > Spring Boot' 카테고리의 다른 글

Spring Boot_예외 처리 기술 (Exception)  (0) 2023.04.18
Spring Boot_MyBatis 설정  (0) 2023.04.18
Spring Boot_인터셉터(Interceptor)  (0) 2023.04.13
Spring Boot_필터(Filter)  (0) 2023.04.13
Spring Boot_예외 처리  (0) 2023.04.13