Spring 数据初始 H2 后进行数据查询提示 Schema not found 错误


在运行测试的错误有提示下面的错误:

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Schema "DBO" not found; SQL statement: select myscofile0_.id as id1_1_0_, myscofile0_.dateC as datec2_1_0_, myscofile0_.dateM as datem3_1_0_, myscofile0_.uuid as uuid4_1_0_, myscofile0_.client_id as client_i5_1_0_, myscofile0_.file_name as file_nam6_1_0_, myscofile0_.file_row_count as file_row7_1_0_, myscofile0_.file_status as file_sta8_1_0_ from dbo.MYSCOFILE myscofile0_ where myscofile0_.id=? [90079-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:576) at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) at org.h2.message.DbException.get(DbException.java:205) at org.h2.message.DbException.get(DbException.java:181) at org.h2.command.Parser.readTableFilter(Parser.java:1940) at org.h2.command.Parser.parseSelectFromPart(Parser.java:2827) 

问题和解决

出现上面的问题是在 JPA 实例的时候配置了 schema = "dbo, 但是 H2 数据库进行初始化的时候没有创建 schema。

 

 

针对上面的问题,你需要在你的 H2 初始化的时候创建一个 schema。

创建 schema 的脚本为:

CREATE SCHEMA IF NOT EXISTS DBO; SET SCHEMA DBO; 

通过添加下面的脚本,将会在 H2 中创建 Schema,然后可以通过控制台中查看创建的情况。

 

 

在完成上面的配置后,再重新运行你的测试,你就会看到上面的错误已经没有错误了。

https://www.ossez.com/t/spring-h2-schema-not-found/605


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM