我正在使用 JHipster,当我使用 docker-compose 启动应用程序时,应用程序无法连接到数据库。启动时是否需要创建数据库用户?
gestao-app_1 | org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres"
应用程序.yml
version: '2'
services:
gestao-app:
image: gestao
environment:
- _JAVA_OPTIONS=-Xmx512m -Xms256m
- SPRING_PROFILES_ACTIVE=prod,swagger
- MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true
- SPRING_DATASOURCE_URL=jdbc:postgresql://gestao-postgresql:5432/mydb
- JHIPSTER_SLEEP=30 # gives time for other services to boot before the application
ports:
- 8080:8080
gestao-postgresql:
extends:
file: postgresql.yml
service: gestao-postgresql
postgresql.yml
version: '2'
services:
gestao-postgresql:
image: postgres:11.3
volumes:
- ~/volumes/jhipster/Gestao/postgresql/:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=1234
- POSTGRES_DB=mydb
ports:
- 5432:5432
应用程序-prod.yml
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:postgresql://localhost:5432/gestao_dev
username: gestao
password: gestao
hikari:
poolName: Hikari
auto-commit: false