Spring Cloud Config Client启动警告:无法连接配置服务器
解决Spring Cloud Config Client连接失败的警告
嘿,你遇到的这个警告原因很明确:你添加了Config Client依赖,而Spring Cloud Config Client默认会自动去连接运行在http://localhost:8888的Spring Cloud Config Server——但你现在根本没启动这个配置服务器,所以自然会出现连接被拒绝的错误啦。
下面给你两种解决方案,根据你的实际需求选就行:
方案一:如果你确实需要使用配置中心
那你得先搭建并启动Config Server:
- 新建一个Spring Boot项目,添加
Spring Cloud Config Server组件 - 在这个新项目的配置文件(比如
application.properties)里做基础配置:# 指定Config Server的端口,默认就是8888,和Client的默认配置对应 server.port=8888 # 配置存放配置文件的Git仓库地址,比如你自己的GitHub/Gitee仓库 spring.cloud.config.server.git.uri=https://github.com/your-repo/config-repo - 启动这个Config Server,之后再启动你的
limits-service,连接问题就解决了。
方案二:暂时不需要配置中心?
那可以直接禁用Config Client的自动行为:
- 要么直接从pom.xml里移除
spring-cloud-starter-config依赖:<!-- 把这段依赖删掉 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> - 要么在你的
limits-service的配置文件里添加一行配置,关闭Config Client功能:
这样应用启动时就不会再去尝试连接8888端口的服务器了。spring.cloud.config.enabled=false
另外,如果你自己手动在配置文件里指定了spring.cloud.config.uri,那也要确保这个地址对应的服务器是正常运行的哦。
内容的提问来源于stack exchange,提问作者Madu
相关产品推荐
相关产品推荐

