spring - PostgreSQL hibernate 和 Spring

标签 spring postgresql hibernate jdbc

我正在尝试将 Hibernate 与 Spring 和 PostgreSQL 一起使用,但我遇到了很多错误,例如:

org.postgresql.Driver   : Connection error 
ERROR 3424 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

我已将 postgreSQL.Driver 放入我的库中,但没有任何可做的错误提示。

编辑:

2018-03-19 15:54:53.660  INFO 7640 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2018-03-19 15:54:54.664  WARN 7640 --- [           main] unknown.jul.logger                       : ConnectException occurred while connecting to localhost:5432`
`at com.ttmik.back.MainKt.main(main.kt:19) ~[classes/:na]
2018-03-19 15:54:54.675 ERROR 7640 --- [           main] org.postgresql.Driver                    : Connection error:

org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

最佳答案

检查是否可以使用 telnet 访问您的 PostgreSQL。如果你得到类似的东西:

telnet localhost 5432
Connecting To localhost... 
Could not open connection to the host, on port 5432: Connection failed

然后很可能需要根据 this answer on serverfaultpostgresql.conf 文件中的 listen_addresses 更改为 * .

关于spring - PostgreSQL hibernate 和 Spring ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49365733/

相关文章:

正则表达式清理带有空格的 id 并从字符串中提取

sql - 空值的质量合并

java - 无法将项目列表发送到后端以从列表中删除

java - 确保@Controller 不一致

java - 使用 xml 实体监听器时未 Autowiring 的依赖项

spring - 如何使用 WebClient 使用响应式 Spring Rest API

java - 我可以在 Spring bean 定义中使用相对路径吗?

ruby-on-rails - 在使用不同的应用程序一段时间后,Rails 应用程序无法找到与 postgres 的连接

java - Spring @Transactional 基于方法级别的条件

java - @EmbeddId 在 hibernate 中抛出 org.hibernate.id.IdentifierGenerationException : null id generated while using . save() 函数