我为我的应用程序创建了一个新环境并将其命名为 docker。我正在尝试一些东西,所以我这样设置:
应用程序-docker.yml
micronaut:
application:
name: time
server:
netty:
access-logger:
enabled: true
logger-name: access-logger
datasources:
default:
url: jdbc:postgresql://db:5432/postgres
driverClassName: org.postgresql.Driver
username: postgres
password: postgres
schema-generate: CREATE_DROP
dialect: POSTGRES
schema: time
jpa.default.properties.hibernate.hbm2ddl.auto: update
flyway:
datasources:
default:
enabled: true
schemas: time
...
但是,当我尝试像这样运行我的应用程序时:
java -jar target/timeshare-0.1.jar -Dmicronaut.environments=docker -Dcom.sun.management.jmxremote -Xmx128m
如果失败......因为它无法连接到本地主机!
08:11:00.949 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
08:11:02.013 [main] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Exception during pool initialization.
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.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:285)
为什么它试图连接到本地主机?我错过了什么?