Spring 内存中与 postgresql 兼容的 h2 的启动属性
Spring boot properties for compability h2 in memory with posgresql
各位。
我在兼容 h2 in-memory 和 postgresql 方面遇到了一些麻烦。我试图在堆栈溢出和 google 中找到我的解决方案,但每个人都使用 Gradle 或其他配置文件。就我而言,我使用 application.properties 文件,但在 SQL 语句中出现语法错误。
我的错误:
enter image description here
我的资源结构:
enter image description here
例如,我的 sql 脚本的一部分:
CREATE TABLE candle_1day
(
id serial primary key NOT NULL,
created_at timestamp(6) without time zone, --> not compability type
open_price numeric(35, 15) CHECK ( open_price >= 0 ),
close_price numeric(35, 15) CHECK ( close_price >= 0 ),
high_price numeric(35, 15) CHECK ( high_price >= 0 ),
low_price numeric(35, 15) CHECK ( low_price >= 0 ),
volume numeric(35, 15) CHECK ( volume >= 0 ),
currency_id integer NOT NULL,
CONSTRAINT unq_candle_1day_currency_id_created_at_idx UNIQUE (currency_id, created_at),
CONSTRAINT fk_candle_1day_currency_id_to_currency_info_id
FOREIGN KEY (currency_id) REFERENCES currency_info (id)
);
我的 application.properties 文件:
spring.datasource.driver-class-name=org.h2.Driver
spring.flyway.user=sa
spring.flyway.password=sa
spring.flyway.schemas=testdb
spring.flyway.url=jdbc:h2:mem:testdb;MODE=PostgreSQL;database_to_upper=false
spring.flyway.locations=filesystem:migration
H2 只能从 1.4.197 版本(当前版本是 1.4.200)开始解析 TIMESTAMP(6) WITHOUT TIME ZONE
。
另请注意,DATABASE_TO_UPPER=FALSE
只能用于 1.4.197 及更旧版本。在较新的版本中,您需要 DATABASE_TO_LOWER=TRUE
才能使用此兼容模式。
各位。 我在兼容 h2 in-memory 和 postgresql 方面遇到了一些麻烦。我试图在堆栈溢出和 google 中找到我的解决方案,但每个人都使用 Gradle 或其他配置文件。就我而言,我使用 application.properties 文件,但在 SQL 语句中出现语法错误。
我的错误: enter image description here
我的资源结构: enter image description here
例如,我的 sql 脚本的一部分:
CREATE TABLE candle_1day
(
id serial primary key NOT NULL,
created_at timestamp(6) without time zone, --> not compability type
open_price numeric(35, 15) CHECK ( open_price >= 0 ),
close_price numeric(35, 15) CHECK ( close_price >= 0 ),
high_price numeric(35, 15) CHECK ( high_price >= 0 ),
low_price numeric(35, 15) CHECK ( low_price >= 0 ),
volume numeric(35, 15) CHECK ( volume >= 0 ),
currency_id integer NOT NULL,
CONSTRAINT unq_candle_1day_currency_id_created_at_idx UNIQUE (currency_id, created_at),
CONSTRAINT fk_candle_1day_currency_id_to_currency_info_id
FOREIGN KEY (currency_id) REFERENCES currency_info (id)
);
我的 application.properties 文件:
spring.datasource.driver-class-name=org.h2.Driver
spring.flyway.user=sa
spring.flyway.password=sa
spring.flyway.schemas=testdb
spring.flyway.url=jdbc:h2:mem:testdb;MODE=PostgreSQL;database_to_upper=false
spring.flyway.locations=filesystem:migration
H2 只能从 1.4.197 版本(当前版本是 1.4.200)开始解析 TIMESTAMP(6) WITHOUT TIME ZONE
。
另请注意,DATABASE_TO_UPPER=FALSE
只能用于 1.4.197 及更旧版本。在较新的版本中,您需要 DATABASE_TO_LOWER=TRUE
才能使用此兼容模式。