.sql 파일 생성 후 SpringBoot 실행 시 오류 발생(h2DB)

LeeYulhee·2023년 8월 29일
0

👉 오류 내용


Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-08-30T00:05:33.140+09:00 ERROR 2216 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ARTICLE" not found (this database is empty); SQL statement:


👉 해결 방법


spring:
  jpa:
    # 테이블 생성 후에 .sql 파일 실행
    defer-datasource-initialization: true
  • application.yml에 defer-datasource-initialization: true 추가
    • 테이블 생성 후에 sql 파일 실행되게 하는 설정
profile
공부 중인 신입 백엔드 개발자입니다

0개의 댓글