Hibernate 초기화 전 data.sql 먼저 실행되어 발생하는 오류

배세훈·2022년 3월 19일
0

error

목록 보기
1/1

개발 환경: SpringBoot(2.5x), Spring Data JPA, h2

오류내용

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/shbae/IdeaProjects/fastcampus/build/resources/main/data.sql]: call next value for hibernate_sequence; nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Sequence "HIBERNATE_SEQUENCE" not found; SQL statement:
call next value for hibernate_sequence [90036-200]~

오류원인

SpringBoot 공식문서

위 오류는 Hibernate가 초기화되기 전에 data.sql이 먼저 실행되어서 발생하는 오류입니다.

해결방법

해결 방법으로 application 설정파일에 spring.jpa.defer-datasource-initialization: true로 설정해주면 됩니다.

profile
성장형 인간

0개의 댓글