0

我正在尝试使用本机文件位置启动一个简单的配置服务器。

服务器的配置如下所示

server:
  port: 9001

spring:
  cloud:
    config:
      server:
        native:
          search-locations: file://${HOME}/Desktop/config2

但是,当客户端服务器启动时使用以下配置

server.port=9002
spring.application.name=client-server
spring.config.import=optional:configserver:http://localhost:9001/
2021-12-01 09:47:07.563  INFO 14992 --- [           main] o.s.b.context.config.ConfigDataLoader    : Fetching config from server at : http://localhost:9001/
2021-12-01 09:47:07.563  INFO 14992 --- [           main] o.s.b.context.config.ConfigDataLoader    : Connect Timeout Exception on Url - http://localhost:9001/. Will be trying the next url if available
2021-12-01 09:47:07.563  WARN 14992 --- [           main] o.s.b.context.config.ConfigDataLoader    : Could not locate PropertySource ([ConfigServerConfigDataResource@674bd420 uris = array<String>['http://localhost:9001/'], optional = true, profiles = list['local']]): I/O error on GET request for "http://localhost:9001/client-server/local": Invalid Http response; nested exception is java.io.IOException: Invalid Http response

有人有什么想法吗?

我调试到resttemplate并且请求形成正常,但是返回的httpStatusCd是-1。

谢谢

4

1 回答 1

0

经过一番调查,从 spring-cloud web 中找到了这个文档:

客户端使用情况

默认情况下,服务在端口 8888 上运行,设置后

spring:
  cloud:
    config:
      allow-override: true

这允许配置服务器更改端口,客户端也可以使用覆盖端口与配置服务器通信,即 8887

添加覆盖更改后,客户端看起来像

server.port=9003
spring.application.name=client-server
spring.config.import=configserver:http://localhost:8887/
于 2021-12-01T12:34:11.960 回答