Spring Boot initialization 的时候,我用了data.sql, 以及h2内存数据库,然后提示找不到表,报了如下错误
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Users//coding/guru/spring5/spring5-recipe-app/target/classes/data.sql]: INSERT INTO category (description) VALUES(“American”); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Table “CATEGORY” not found; SQL statement:
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table “**” not found; SQL statement
在网上找到解决方法:
在application.properties里面添加配置可以解决:
spring.jpa.defer-datasource-initialization=true