spring - 创建成功后找不到Spring H2创建的表
问题描述
我正在使用 Spring Boot 的schema.sql
魔法来创建一个内存 H2 数据库。该脚本包含以下语句:
create table PERSON
(
ID BIGINT not null primary key,
NAME VARCHAR(255) not null
);
create index IDX_PERSON_NAME on PERSON (NAME);
启动 Spring Boo 时失败,但出现以下异常:
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #2 of URL [file:/D:/git/.../build/resources/main/schema.sql]: create index IDX_PERSON_NAME on PERSON (NAME); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "PERSON" not found; SQL statement:
create index IDX_PERSON_NAME on PERSON (NAME) [42102-200]
语句怎么找不到前面语句创建的表呢?
解决方案
以下是可能的原因,
- 在引用表时需要提及架构
test_schema.person
- 您创建索引的语法可能是错误的。有关 H2 语法,请参阅此链接,https://www.baeldung.com/spring-yaml
推荐阅读
- vue.js - Vuetify 数据表中选定行的计算属性未刷新
- r - 使用分类数据创建折线图
- html - 从 Vue 中的 html 和 body 元素中删除边距和填充?
- css - Dompdf对齐两个文本块
- javascript - 将 Treant.js 合并到 Vue.js 应用程序中
- ruby-on-rails - 使用 roo gem 将从 xlsx 提取的哈希存储在 ruby 中的数据库中
- ios - 为什么我不能在模拟器中点击 uibutton 但我可以在我的硬件 iPhone 上点击?
- flutter - 为什么我的异步函数返回一个 Future
每个人都在等待? - django - quizgame 在生产中随机获取重复项
- java - 比较法违反其使用日期的一般合同例外