Search code examples
postgresqlspring-mvcherokuspring-bootheroku-postgres

Spring Boot MVC application with Postgresql deployment failed in Heroku


I have a Spring Boot MVC project. It works fine with h2 database and also fine in local postgre database with following application.properties configuration

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

But when I am trying to deploy it in Heroku it is getting this following error:

Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

If I use this configuration

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

I am getting this when try to run my project from STS and failed deployment.

Caused by: java.sql.SQLException: Driver:org.postgresql.Driver@17a3dff6 returned null for URL:myUrl

My pom is :

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

Can any body help ?


Solution

  • You need a proper JDBC url. See: https://springframework.guru/configuring-spring-boot-for-postgresql/