作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个 Spring Boot 项目,我试图将我的服务器连接到一个 postgresql 数据库。
当我使用我的 IDE(在我的 Windows 操作系统上)运行程序时,它正在工作,但是当我制作一个 jar 文件并在托管我的数据库的 ubuntu 服务器虚拟机上运行它时,它不起作用。
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.
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
listen_addresses = '*' # what IP address(es) to listen on;
ssl = on
local all postgres peer
local all kapitax trust
# TYPE DATABASE USER ADDRESS METHOD
#host all kapitax * password
#host all all 0.0.0.0/0 md5
# "local" is for Unix domain socket connections only
local all all * trust
# IPv4 local connections:
host all all * password
# IPv6 local connections:
host all all ::1/128 password
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all * md5
host replication all ::1/128 md5
spring.datasource.url= jdbc:postgresql://localhost:5432/kapitax
spring.datasource.username=kapitax
spring.datasource.password=kapitax
spring.jpa.hibernate.ddl-auto=create-drop
server.port=8090
最佳答案
线
#host all all 0.0.0.0/0 md5
host all all 0.0.0.0/0 md5
0.0.0.0/0
您将监听所有 IPv4 地址。更改此配置后,请确保重新加载服务器设置或重新启动数据库服务器。更详细的解释可以在以下答案中找到:
How to configure PostgreSQL to accept all incoming connections
关于java - 如何将 Spring Boot Web 应用程序连接到 postgresql 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54833088/
我是一名优秀的程序员,十分优秀!