멍청멍청기록/에러 일기

스프링부트] 초기화 전 data.sql 실행되서 발생되는 에러

  • -
728x90
반응형

Mac M1 pro // OS Ventura 13.6 

Springboot 3.2

java 17


Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Failed to execute SQL script statement #1 of file

 

스프링부트가 첫 실행 시 디렉터리안에 data.sql이 먼저 실행되서 그렇다

 

application.yml 파일 수정 전

spring: datasource: url: jdbc:h2:tcp://localhost/~/h2testdb username: sa password: driver-class-name: org.h2.Driver h2: console: enabled: true jpa: hibernate: ddl-auto: create-drop properties: hibernate: format_sql: true sql: init: mode: always

 

yml파일에 아래를 추가한다.

defer-datasource-initialization: true

 

application.yml 파일 수정 후

spring: datasource: url: jdbc:h2:tcp://localhost/~/h2testdb username: sa password: driver-class-name: org.h2.Driver h2: console: enabled: true jpa: hibernate: ddl-auto: create-drop properties: hibernate: format_sql: true defer-datasource-initialization: true sql: init: mode: always

 

 

반응형

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.