환경
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