【问题标题】:Creating a Postgres database with JDBC Driver when starting a SpringBoot app?启动 SpringBoot 应用程序时使用 JDBC 驱动程序创建 Postgres 数据库?
【发布时间】:2021-08-07 10:28:38
【问题描述】:

当我想在 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 数据库?

【问题讨论】:

    标签: postgresql spring-boot jdbc


    【解决方案1】:

    Postgres 不支持通过 JDBC URL 按需创建数据库。您可以在documentation 中了解可以进行哪些配置。

    【讨论】:

      猜你喜欢
      • 2014-02-05
      • 2021-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-09
      • 1970-01-01
      • 2013-08-12
      相关资源
      最近更新 更多