Spring Boot:H2 测试数据库无法识别“serial4”
我在内存中使用 h2 来测试 spring 存储库类。 但是当 h2 尝试创建表时返回:
org.h2.jdbc.JdbcSQLNonTransientException: Unknown data type: "SERIAL4";
表的ddl显示id列是serial4数据类型。
id serial4 NOT NULL
但 h2 无法识别这一点。 原始表位于 postgresql 下。
有什么类型的解决方案吗?
谢谢
更新:
我已经更新了测试环境的applications.yaml,但结果是一样的。这是更新后的 yaml 文件:
spring:
application:
name: test_name
jpa:
database-platform: org.hibernate.dialect.H2Dialect
show-sql: true
properties:
generate-ddl: true
hibernate:
ddl-auto: create
format_sql: true
jdbc:
batch_size: 500
lob:
non_contextual_creation: true
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:mydb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_LOWER=TRUE;MODE=POSTGRESQL;INIT=CREATE SCHEMA IF NOT EXISTS test_schema\;
logging:
level:
root: INFO
I'm using h2 as in memory in order to test a spring repository class.
But when h2 try to create the table return:
org.h2.jdbc.JdbcSQLNonTransientException: Unknown data type: "SERIAL4";
The ddl of the table show that the id column is a serial4 datatype.
id serial4 NOT NULL
But h2 don't recognize that.
The origina table is under postgresql.
There is any type of solution?
Thanks
UPDATE:
I've updated the applications.yaml of test enviroment, but the result is the same. Here's the updated yaml file:
spring:
application:
name: test_name
jpa:
database-platform: org.hibernate.dialect.H2Dialect
show-sql: true
properties:
generate-ddl: true
hibernate:
ddl-auto: create
format_sql: true
jdbc:
batch_size: 500
lob:
non_contextual_creation: true
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:mydb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_LOWER=TRUE;MODE=POSTGRESQL;INIT=CREATE SCHEMA IF NOT EXISTS test_schema\;
logging:
level:
root: INFO
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论