加载中...

spring cloud config (Unable to start web server)


a. 问题描述:Unable to start web server

b. 产生原因:
        spring cofigconfigClient启动时默认从本地的configServer,即Fetching config from server at : http://localhost:8888进行配置拉取,此时,configClient应用的application.properties中的配置无效!因为该配置按理应该从configServer进行拉取,而后configClient根据拉取到的配置进行启动!

注意:下述操作在configClient端!!!

c. 解决方法:
        创建一个spring cloud中特有的bootstrap.yml/bootstrap.properties文件,改文件属于引导配置文件,具有比application.properties更加优先的加载顺序。

# 配置服务器在注册中心的服务名
spring.cloud.config.discovery.service-id=CONFIGSERVER
# 启动配置服务发现,从注册中心拉取配置服务器的服务列表,根据负载均衡选择一个具体配置服务器进行配置拉取
spring.cloud.config.discovery.enabled=true
# consul注册中心地址(自定义修改)
spring.cloud.consul.host=192.168.80.130
# consul默认注册端口
spring.cloud.consul.port=8500
# 将本服务以ip地址的方式注册到注册中心
spring.cloud.consul.discovery.prefer-ip-address=true
# consul注册中心需要对本服务进行健康检查,使用到 springboot的组件actuator的功能
spring.cloud.consul.discovery.health-check-url=http://192.168.80.1:${server.port}/actuator/health/

# 远端配置分支标签名
spring.cloud.config.label=master
# 配置名(一般以服务名命名)
spring.cloud.config.name=configclient
# 具体配置服务环境名
spring.cloud.config.profile=dev

posted @ 2022-03-25 15:40  dada-hua  阅读(263)  评论(0编辑  收藏  举报