hanker
Spring boot - boot 실행 시 sql 문 실행 본문
Spring boot를 실행 시 SQL문을 실행하는 법에 대해 알아보자
우선 Spring boot 실행 시 MEMBERS 테이블을 만들려고 한다.
- 실행하려는 SQL문
- application.properties에 설정을 한다. (H2 사용)
## H2 Database 사용 설정
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:~/test
spring.datasource.username=sa
spring.datasource.password=
# Spring boot 시작 시 sql 문 실행
spring.sql.init.mode=always
- 사용 설정이 완료되면, /resources/ 경로에 schema.sql을 넣어주고, boot를 실행시킨다.
'SPRING' 카테고리의 다른 글
Spring Boot - 이메일 전송(1)(JavaMailSender) (2) | 2021.10.04 |
---|---|
Spring Security - 로그인 경로 지정(java) (0) | 2021.08.25 |
Spring JPA - referencedColumnName (feat. @JoinColumn) (0) | 2021.05.27 |
Spring - Security Static 경로 인증 무시(403 Error) (0) | 2021.05.09 |
Spring boot - HTML 입력값 검사 ( Valid example ) (0) | 2021.04.30 |