Contents
application.propertiesapplication.properties
# 3. 더미데이터 세팅
spring.sql.init.data-locations=classpath:db/data.sql
spring.jpa.defer-datasource-initialization=true
- spring.sql.init.data-locations=classpath:db/data.sql
- db 폴더 안의 data.sql 안의 코드를 실행
- spring.jpa.defer-datasource-initialization=true
- 테이블을 생성하고 초기화
- data.sql이 테이블 생성 전에 실행되는 것을 막아줍니다.
data.sql
- resources 폴더 안에 db 디렉터리 안에 생성합니다.
insert into board_tb(title, content, created_at) values ('제목1', '내용1', now());
insert into board_tb(title, content, created_at) values ('제목2', '내용2', now());
insert into board_tb(title, content, created_at) values ('제목3', '내용3', now());
insert into board_tb(title, content, created_at) values ('제목4', '내용4', now());
insert into board_tb(title, content, created_at) values ('제목5', '내용5', now());
- 5개의 row를 삽입해 줍니다.
Share article