【问题标题】:Heroku FlywayException: Unable to autodetect JDBC driver for urlHeroku FlywayException:无法自动检测 url 的 JDBC 驱动程序
【发布时间】:2020-12-19 20:48:16
【问题描述】:

我尝试将我的应用部署到 Heroku。我可以看到日志有如下异常:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is org.flywaydb.core.api.FlywayException: Unable to autodetect JDBC driver for url: jdbc:postgres://hostname:5432/databaseName.

我知道为什么我有这个例外,因为 jdbc:postgres://... 在 url。 Flyway 期望这样的 url:jdbc:postgresql://.... 来定义驱动程序。但是 Heroku 提供的数据库 url 没有后缀 ql。我该如何解决?

【问题讨论】:

    标签: spring spring-boot heroku flyway heroku-postgres


    【解决方案1】:

    当我看到heroku提供的这个网址时,我有点困惑。

    postgres://host_name:5432/database_name
    

    但我只是把它改成了

    spring.flyway.url=jdbc:postgresql://${DB_HOST}:5432/${DB_NAME}
    

    之前我有

    spring.flyway.url=jdbc:${DATABASE_URL} => postgres://host_name:5432/database_name
    

    我只是将 postgres 替换为 postgresql 现在我对 flyway 没有任何问题。

    【讨论】:

      猜你喜欢
      • 2022-09-23
      • 2012-03-09
      • 1970-01-01
      • 2016-08-09
      • 2020-10-29
      • 2013-03-03
      • 2015-10-10
      • 2017-05-17
      • 2017-01-15
      相关资源
      最近更新 更多