【问题标题】:Spring Boot MVC application with Postgresql deployment failed in Heroku具有 Postgresql 部署的 Spring Boot MVC 应用程序在 Heroku 中失败
【发布时间】:2017-06-04 10:25:25
【问题描述】:

我有一个 Spring Boot MVC 项目。它适用于 h2 数据库,也适用于具有以下 application.properties 配置的本地 postgre 数据库

spring.datasource.url=myUrl
spring.datasource.username=myUsername
spring.datasource.password=myPassword

但是当我尝试在 Heroku 中部署它时,出现以下错误:

引起:org.hibernate.HibernateException:访问 未设置“hibernate.dialect”时,DialectResolutionInfo 不能为空

如果我使用这个配置

spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=herokuPostgreSqlDbUrl
spring.datasource.username=herokuUsername
spring.datasource.password=mherokuPassword

我在尝试从 STS 运行我的项目但部署失败时遇到此问题。

原因:java.sql.SQLException: Driver:org.postgresql.Driver@17a3dff6 为 URL:myUrl 返回 null

我的 pom 是:

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4-1206-jdbc42</version>
        </dependency>

任何机构都可以帮忙吗?

【问题讨论】:

    标签: postgresql spring-mvc heroku spring-boot heroku-postgres


    【解决方案1】:

    您需要一个正确的 JDBC 网址。见:https://springframework.guru/configuring-spring-boot-for-postgresql/

    【讨论】:

    • 我使用 spring.datasource.url=jdbc:postgres://ec2-54-235-124-2.compute-1.amazonaws.com:5432/xyzDbname 作为 jdbc url 可以吗?
    猜你喜欢
    • 1970-01-01
    • 2021-07-25
    • 2017-03-12
    • 2014-05-27
    • 2016-03-23
    • 2019-01-17
    • 2018-05-13
    • 2018-07-14
    • 2018-11-19
    相关资源
    最近更新 更多