[英]Springboot Config server client returns status code: -1
我正在嘗試使用本機文件位置啟動一個簡單的配置服務器。
服務器的配置如下所示
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。
謝謝
經過一番調查,從 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/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.