如何解决spring cloud配置中心客户端启动遇到的问题
发表于:2026-11-03 作者:千家信息网编辑
千家信息网最后更新 2026年11月03日,如何解决spring cloud配置中心客户端启动遇到的问题,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。spring cloud
千家信息网最后更新 2026年11月03日如何解决spring cloud配置中心客户端启动遇到的问题
如何解决spring cloud配置中心客户端启动遇到的问题,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
spring cloud 配置中心客户端启动
先启动了配置中心,然后启动客户端,
发现打印的日志是这样的
2020-04-29 11:13:02.333 INFO 1856 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:9009/2020-04-29 11:13:08.121 INFO 1856 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=test-config, profiles=[dev], label=master, version=3eb2b779d066af89af4ba5b7a722d2189a15ffd3, state=null2020-04-29 11:13:08.122 INFO 1856 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/kzdw/springCloudConfigCenter.git/test-config.yml (document #1)'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/kzdw/springCloudConfigCenter.git/test-config.yml (document #0)'}]2020-04-29 11:13:08.127 INFO 1856 --- [ main] c.z.c.ConfigCloudClientApplication : The following profiles are active: dev2020-04-29 11:13:08.408 INFO 1856 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=3bad3006-6836-326e-9ae4-7b60b788ec282020-04-29 11:13:08.720 INFO 1856 --- [ main] c.z.c.ConfigCloudClientApplication : Started ConfigCloudClientApplication in 7.436 seconds (JVM running for 8.236)从日志上看,已经获取到了配置中心的配置,但是呢,总感觉日志不对,怎么就没有启动的端口呢。
springcloud经常会一个模块包含另外模块,难道web模块没有被 spring-cloud-starter-config 包含?
那就加入web模块吧
org.springframework.boot spring-boot-starter-web
加入之后再启动项目
2020-04-29 11:20:35.379 INFO 10060 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:9009/2020-04-29 11:20:36.849 INFO 10060 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=test-config, profiles=[dev], label=master, version=3eb2b779d066af89af4ba5b7a722d2189a15ffd3, state=null2020-04-29 11:20:36.850 INFO 10060 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/kzdw/springCloudConfigCenter.git/test-config.yml (document #1)'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/kzdw/springCloudConfigCenter.git/test-config.yml (document #0)'}]2020-04-29 11:20:36.855 INFO 10060 --- [ main] c.z.c.ConfigCloudClientApplication : The following profiles are active: dev2020-04-29 11:20:37.278 INFO 10060 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=21eb9db3-9e16-3c20-bd81-2c0ea23b0f122020-04-29 11:20:37.566 INFO 10060 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8201 (http)2020-04-29 11:20:37.574 INFO 10060 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]2020-04-29 11:20:37.574 INFO 10060 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]2020-04-29 11:20:37.684 INFO 10060 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext2020-04-29 11:20:37.684 INFO 10060 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 817 ms2020-04-29 11:20:37.851 INFO 10060 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'2020-04-29 11:20:38.200 INFO 10060 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8201 (http) with context path ''2020-04-29 11:20:38.285 INFO 10060 --- [ main] c.z.c.ConfigCloudClientApplication : Started ConfigCloudClientApplication in 3.87 seconds (JVM running for 4.531)果然,从配置中心拉取到了配置并成功启动了。
spring cloud配置中心客户端配置的坑
1. 出错信息如下
在启动配置中心的客户端时,报以下错误信息:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'foo' in value "${foo}"
2. 度娘查了下,发现很多人碰到这个坑
首先我提交到git上到配置文件名称为下面两个文件
cloud-config-dev.propertiescloud-config-test.properties
遵循配置中心配置文件的规则/{application}-{profile}.properties
所以在cloud-config-client端调用的时候,applcation.name应该是cloud-config,然而我在配置的时候,想当然的写成了cloud-config-client,导致出现上面的错误。
解决方法很简单,贴下client的配置如下
关于如何解决spring cloud配置中心客户端启动遇到的问题问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注行业资讯频道了解更多相关知识。
配置
客户
客户端
问题
模块
文件
日志
信息
方法
时候
更多
错误
帮助
解答
不对
易行
成功
想当然
简单易行
两个
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
广州淘业互联网络科技
互联网科技公司华为
互联网金融科技平台
广西互联网科技公司
互联网科技咨询
互联网科技大会案例
以后互联网后是啥科技
互联网公司科技股
民营互联网公司国防科技
河南住房之家互联网科技
华夏恒生互联网科技013171
皮皮虾互联网科技有限公司
互联网营销推广黑科技
宇信科技在杭州互联网排第几
风投北京互联网科技
扫呗互联网科技有限公司
广西科技产业互联网是什么
互联网金融运营模式中的金融科技
互联网科技大佬云集
黑龙江互联网科技公司
互联网科技
互联网与科技
新华互联网科技
互联网科技革命
新华互联网科技2019
互联网科技热点资讯
互联网教育科技公司vipkid
常德市电业局互联网科技部
武汉健翔互联网络科技有限公司
唯美互联网科技