致命:主机"172.21.144.1"、用户"smath"、数据库"customer"、无加密的 pg_hba.conf 条目



我需要你的帮助。我是spring-boot的新手,我正在学习一门关于微服务和spring-cloud的课程。我有一个基本的应用程序,并用postgres在docker上建立数据库。

我正试图将我的spring-boot应用程序连接到我在docker上运行的postgresql数据库,这是我得到的错误:

FATAL: no pg_hba.conf entry for host "172.21.144.1", user "smath", database "customer", no encryption

这看起来像是一个加密错误,但我不知道如何解决这个问题

这是我的申请。yml文件

server:
port: 8080
spring:
application:
name: customer
datasource:
username: 'smath'
url: jdbc:postgresql://postgres:5432/customer
password: 'smath'
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
format_sql: 'true'
hibernate:
ddl-auto: update
show-sql: 'true'

我的pg_hba.conf文件看起来像这个

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    customer        smath           172.21.144.1            md5
# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             0.0.0.0/0               scram-sha-256
# host    all             all             127.0.0.1/32            scram-sha-256
# IPv6 local connections:
host    all             all             ::1/128                 scram-sha-256

加上这是我的docker合成文件

services:
postgres:
container_name: postgres
image: postgres
environment:
POSTGRES_USER: smath
POSTGRES_PASSWORD: smath
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
ports:
- "5432:5432"
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- pgadmin:/var/lib/pgadmin
ports:
- "5050:80"
networks:
- postgres
restart: unless-stopped
networks:
postgres:
driver: bridge
volumes:
postgres:
pgadmin:

我会感谢你的帮助

我找到了一个解决方案。这是我本地安装的postgres和docker安装的版本之间的冲突。我只是停止了当地一家的服务,一切都很好。

最新更新