- 토이프로젝트인 점을 고려하여 초기 세팅 기간에는 메모리 DB를 사용하고 Mysql Employee 샘플 데이터 일부를 사용하기로 하였다.
- 우선 h2 db를 연결하기 위해 property 설정을 해준다.
// database 연결을 위한 세팅
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
// h2 db 접속 및 데이터 초기화를 위한 세팅
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.sql.init.mode=embedded
spring.sql.init.data-locations: classpath:db/data.sql
spring.sql.init.schema-locations: classpath:db/schema.sql
- db 데이터 초기화와 관련된 초기 세팅 경로는 아래와 같이 해준다.
- 만약 JPA를 이용한 auto ddl 또는 이미 세팅된 db에 연결할 경우 아래의 sql파일 및 properties의 init 설정은 삭제한다.
/main
/kotlin
/resources
/db
data.sql
schema.sql

- 웹 콘솔은 properties 세팅에 적어준 값을 이용해 접속하면 된다.
