Python 官方文档:入门教程 => 点击学习
目录spring cloud 配置中心客户端启动发现打印的日志是这样的那就加入WEB模块吧加入之后再启动项目spring cloud配置中心客户端配置的坑1. 出错信息如下2. 度娘
先启动了配置中心,然后启动客户端,
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=null
2020-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: dev
2020-04-29 11:13:08.408 INFO 1856 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=3bad3006-6836-326e-9ae4-7b60b788ec28
2020-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 包含?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
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=null
2020-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: dev
2020-04-29 11:20:37.278 INFO 10060 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=21eb9db3-9e16-3c20-bd81-2c0ea23b0f12
2020-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 WebApplicationContext
2020-04-29 11:20:37.684 INFO 10060 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 817 ms
2020-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)
果然,从配置中心拉取到了配置并成功启动了。
在启动配置中心的客户端时,报以下错误信息:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'foo' in value "${foo}"
首先我提交到git上到配置文件名称为下面两个文件
cloud-config-dev.properties
cloud-config-test.properties
遵循配置中心配置文件的规则/{application}-{profile}.properties
所以在cloud-config-client端调用的时候,applcation.name应该是cloud-config,然而我在配置的时候,想当然的写成了cloud-config-client,导致出现上面的错误。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: spring cloud 配置中心客户端启动遇到的问题
本文链接: https://lsjlt.com/news/136647.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0