首页 > 解决方案 > spring boot中不同数据库的多个数据库模式

问题描述

我有需要在 PCF 上部署的 Spring Boot 应用程序。我想使用 H2 数据库进行本地测试,但在 PCF 中部署后,我将使用 SQL 服务器。我有一个需要用于每个数据库的架构。所以,我有两个 schema.sql 文件,一个用于 H2,另一个用于 SQL Server。如何告诉 spring 需要使用本地配置文件 schema-H2.sql 以及需要使用配置文件云 schema-sqlserver.sql。

标签: sql-serverspringspring-bootschemapcf

解决方案


You can set the spring.datasource.platform to differentiate the schema and data sql file. eg,

spring.datasource.platform=h2
then the file name should be data-h2.sql and schema-h2.sql

Make sure you set spring.datasource.initialization-mode=always


推荐阅读