【问题标题】:Configuration service throwing exception with DockerDocker 配置服务抛出异常
【发布时间】:2022-01-22 11:18:44
【问题描述】:

好的,我正在学习使用docker 使用微服务 到目前为止,我得到了非常简单的服务,但是当我尝试使用另一个服务配置我的 config-server 时,我得到了一个异常:

例外:

Connect Timeout Exception on Url - http://config-server:8888/. Will be trying the next url if available
2021-12-20 20:26:09.425  WARN [currency-exchange,,] 1 --- [           main] o.s.b.context.config.ConfigDataLoader    : Could not locate PropertySource ([ConfigServerConfigDataResource@72d1ad2e uris = array<String>['http://config-server:8888/'], optional = true, profiles = list['default']]): I/O error on GET request for "http://config-server:8888/currency-exchange/default": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)

配置服务属性:

server.port=8888
spring.application.name=spring-cloud-config-server
spring.cloud.config.server.git.default-label=main
spring.cloud.config.server.git.uri=https://github.com/fastaca/CloudConfig/

如您所见,我将 url 指向 github 存储库。

存储库:

*currency-exchange.yml*

server:
  port: 8007

注意:配置服务镜像名称为config-server

货币兑换属性:

spring.config.import=optional:configserver:http://config-server:8888/
spring.application.name=currency-exchange
spring.cloud.config.enabled=true

docker-compose.yaml:

config-server:
    image: config-server
    ports:
      - "8888:8888"
    networks:
      - currency-network
    environment:
      EUREKA.CLIENT.SERVICEURL.DEFAULTZONE: http://naming-server-microservice:8761/eureka
      SPRING.ZIPKIN.BASEURL: http://zipkin-server:9411/



  currency-exchange-microservice:
    image: currency-exchange-microservice
    networks:
      - currency-network
    depends_on:
      - naming-server-microservice
      - rabbitmq
    environment:
      EUREKA.CLIENT.SERVICEURL.DEFAULTZONE: http://naming-server-microservice:8761/eureka
      SPRING.ZIPKIN.BASEURL: http://zipkin-server:9411/
      RABBIT_URI: amqp://guest:guest@rabbitmq:5672
      SPRING_RABBITMQ_HOST: rabbitmq
      SPRING_ZIPKIN_SENDER_TYPE: rabbit

有趣的是,我尝试运行 contrainer 几次,一次成功,但从那以后我不断收到异常。

对此还是个新手。

【问题讨论】:

    标签: java docker yaml


    【解决方案1】:

    你使用的是什么版本的 docker-compose?

    尝试从每个撰写服务中删除网络部分,然后重试。有时添加网络会导致 docker-compose 中的 dns 混乱。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-06
      • 2012-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-15
      相关资源
      最近更新 更多