报错1:DEBUG org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - Application failed to start due to an exception
ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter -
原因:Spring Cloud 新版本默认将 Bootstrap 禁用,需要将 spring-cloud-starter-bootstrap 依赖引入到工程中
报错2::org.springframework.cloud.config.client.ConfigServerInstanceProvider$Function has not been registered
原因配置文件命名问题:
改成
application.properties就可以了
配置文件命名的命名规则为:
使用Spring Cloud Config Client 获取 Config Server 配置文件时,如果Config Server端口不是8888时,则Config Client的配置文件应该设置为bootstrap.yml,而不是application.yml,bootstrap.yml加载顺序优先于application.yml,否则会获取失败。
上图显示 无法解决占位符${serverPort},这是因为Config Client 客户端没有成功获取到Config Server 服务器(GitHub)上的配置文件信息。故而导致启动失败。
仓库中的配置文件会被转换成web接口,访问可以参照以下的规则:
/{application}/{profile}[/{label}]:
~: /{application}-{profile}.yml
~: /{label}/{application}-{profile}.yml
~: /{application}-{profile}.properties
~: /{label}/{application}-{profile}.properties
Gitee 远程服务器的配置文件需与客户端文件名称对应。如:{application}-{profile}.yml,则标识 Config-Client 客户端应用的名称 + 应用环境。 profile 可以设置为dev(开发环境)、test(测试环境)、pro(正式环境)。以当前客户端为例:GitHub所对应的配置文件为:eureka-config-client-dev.properties。