您好,登錄后才能下訂單哦!
如何解決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=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,導致出現上面的錯誤。
關于如何解決spring cloud配置中心客戶端啟動遇到的問題問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。