【问题标题】:How to use schema-h2.sql如何使用 schema-h2.sql
【发布时间】:2021-05-09 00:54:39
【问题描述】:

Spring Boot 2.4.3.

schema-h2.sql 好像没有效果。

H2 数据库已创建,但未创建表。

schema-h2.sql:

DROP TABLE IF EXISTS Blogger;

CREATE TABLE Blogger(
id bigint NOT NULL,
name varchar(100),
age int,
PRIMARY KEY (id)
);

DROP TABLE IF EXISTS Story;

CREATE TABLE Story(
id bigint NOT NULL,
title varchar(100),
content varchar(400),
posted date,
blogger_id int,
PRIMARY KEY (id)
);

application.properties:

spring.thymeleaf.cache=false
spring.web.locale-resolver=fixed
spring.web.locale=en
spring.h2.console.enabled=true
spring.h2.console.path=/db
spring.datasource.url=jdbc:h2:mem:testdb

有什么建议吗? 谢谢!

【问题讨论】:

    标签: spring-boot


    【解决方案1】:

    找到解决方案,我需要添加 spring.datasource.platform=h2 属性

    【讨论】:

      猜你喜欢
      • 2020-07-28
      • 1970-01-01
      • 2015-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多