Heroku中使用Postgresql部署的Spring Boot MVC应用程序失败

时间:2017-01-19 16:13:49

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

我有一个Spring Boot MVC项目。它适用于h2数据库,在本地postgre数据库中运行良好,具有以下 application.properties 配置

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返回null:myUrl

我的pom是:

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

任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

您需要一个合适的JDBC网址。请参阅:https://springframework.guru/configuring-spring-boot-for-postgresql/

相关问题