resources 에 sql 파일을 추가해서 h2콘솔에서 직접 데이터를 확인해보려 했는데
갑자기
Error 가 발생했다.
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/SungChanWoo/IdeaProjects/zzspringCloudProject/catalog/build/resources/main/data.sql]:
insert into catalog(product_id, product_name, stock, unit_price) values ('CATALOG001', 'Berlin', 100, 1500); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "CATALOG" not found (this database is empty); SQL statement:
이유를 보다보니 database에 catalog 라는 Table 이 존재 하지 않은 상황에서
insert into catalog 를 사용해서 문제가 발생하는 것같다.
Table이 생성되도록 yml 파일을 손봐줘야할 것같다.
yml 파일 수정하기
Hivernate 초기화를 통해 생성된 스키마에다 데이터를 채우기 위해서
data.sql 이 실행되야 한다면
해당 문구를 추가해줘야한다.
spring:
jpa :
defer-datasource-initialization: true
데이터 베이스 커넥션 풀(Database Connection Pool) (0) | 2022.09.24 |
---|---|
데이터 접근 기술 - JDBC (0) | 2022.09.21 |
Hash Table Collision (0) | 2022.08.10 |
Hash (0) | 2022.08.05 |
database [index] (0) | 2022.07.29 |
댓글 영역