对于JHipster微服务体系结构,我在Docker容器中运行一个名为AuthServer的UAA服务器,在另一个容器中运行Jhipster注册表。
docker容器在相同的用户桥网络配置中运行。
由于注册表不在同一个容器中,因此我将UAA服务器配置为连接到application.yml文件中的jhipster-registry计算机
eureka:
instance:
prefer-ip-address: true
client:
service-url:
defaultZone: http://admin:${jhipster.registry.password}@jhipster-registry:8761/eureka/
以同样的方式,我在bootstrap.yml文件中使用了它:
spring:
cloud:
config:
fail-fast: true
retry:
initial-interval: 1000
max-interval: 2000
max-attempts: 100
uri: http://admin:${jhipster.registry.password}@jhipster-registry:8761/config
最后在我的docker-compose文件中,我还使用了
version: '3.3'
services:
authserver-app:
image: authserver
environment:
- _JAVA_OPTIONS=-Xmx512m -Xms256m
- SPRING_PROFILES_ACTIVE=prod,swagger
- EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/eureka
- SPRING_CLOUD_CONFIG_URI=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/config
- SPRING_DATASOURCE_URL=jdbc:postgresql://authserver-postgresql:5432/AuthServer
- JHIPSTER_SLEEP=10 # gives time for the JHipster Registry to boot before the application
但是当我启动应用程序AuthServer时,它会继续尝试连接到本地主机
authserver-app_1 | 2019-01-04 18:07:39.134 DEBUG 1 --- [ restartedMain] c.n.d.s.r.aws.ConfigClusterResolver : Config resolved to [AwsEndpoint{ serviceUrl='http://admin:admin@localhost:8761/eureka/', region='us-east-1', zone='defaultZone'}]
authserver-app_1 | 2019-01-04 18:07:39.141 DEBUG 1 --- [ restartedMain] c.n.d.s.r.a.ZoneAffinityClusterResolver : Local zone=defaultZone; resolved to: [AwsEndpoint{ serviceUrl='http://admin:admin@localhost:8761/eureka/', region='us-east-1', zone='defaultZone'}]
这种有关本地主机的配置来自哪里,我该如何解决?