【发布时间】:2018-10-19 22:25:19
【问题描述】:
我们正在使用 liquibase 和 hibernate 构建一个 Spring Boot 应用程序。 但现在我们面临一些问题。
它适用于 H2,但是当切换到 oracle 时,我们需要添加国家化注释
@Nationalized
public String getCreatedBy() {
但是现在使用 h2 进行模式验证正在破坏:
Schema-validation: wrong column type encountered in column [created_by] in table [foo]; found [varchar (Types#VARCHAR)], but expecting [nvarchar(255) (Types#NVARCHAR)]
解决此问题的正确方法是什么?有没有类似 oracle 和 h2 的映射表的东西?
【问题讨论】:
-
也许可以尝试在 oracle 模式下运行 h2? spring.datasource.url=jdbc:h2:mem:testdb;Mode=Oracle
-
您使用哪个版本的 h2?刚刚在我的项目上使用休眠、弹簧启动和 h2 版本 1.4.196 进行了测试。 @Nationalized 对我来说很好用。
-
我在 oracle 模式下运行,zwingend spring boot 2.0.1。稍后将提供确切的版本
-
我想你的 application.properties 中有 spring.jpa.hibernate.ddl-auto=validate 属性?我重现了你的问题。如果此属性的值“无” - 它的工作原理。如果“验证” - 发生错误。我认为您有两种方法可以解决您的问题。第一种方式 - 将此道具更改为“无”或“更新”。第二种方式 - 为 h2 和 oracle 提供 2 个不同的 application.properties 文件或 spring 配置文件
-
这是一个很好的文档,如何参数化您的应用属性docs.spring.io/spring-boot/docs/current/reference/html/…
标签: java oracle hibernate spring-boot h2