启动 SpringBoot 应用程序时使用 JDBC 驱动程序创建 Postgres 数据库?
Creating a Postgres database with JDBC Driver when starting a SpringBoot app?
当我想在 Springboot 应用程序中使用 Mysql 数据库时,我可以通过类似于此的属性中的字符串在启动时创建它:
spring.datasource.jdbc-url=jdbc:mysql://localhost:3306/testDb?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
尽管如此,PostgreSQL 似乎忽略了这一点:
spring.datasource.jdbc-url=jdbc:postgresql://localhost:5432/testdb?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
有没有办法在 Flyway 尝试启动表之前在启动 SpringBoot 应用程序时创建 PostgreSQL 数据库?
Postgres 不支持通过 JDBC URL 按需创建数据库。您可以在 documentation.
中了解可能的配置
当我想在 Springboot 应用程序中使用 Mysql 数据库时,我可以通过类似于此的属性中的字符串在启动时创建它:
spring.datasource.jdbc-url=jdbc:mysql://localhost:3306/testDb?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
尽管如此,PostgreSQL 似乎忽略了这一点:
spring.datasource.jdbc-url=jdbc:postgresql://localhost:5432/testdb?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
有没有办法在 Flyway 尝试启动表之前在启动 SpringBoot 应用程序时创建 PostgreSQL 数据库?
Postgres 不支持通过 JDBC URL 按需创建数据库。您可以在 documentation.
中了解可能的配置