欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

spring cloud 配置中心客戶端啟動(dòng)遇到的問題

 更新時(shí)間:2021年09月25日 09:18:04   作者:qq_36481502  
這篇文章主要介紹了spring cloud 配置中心客戶端啟動(dòng)遇到的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

spring cloud 配置中心客戶端啟動(dòng)

先啟動(dòng)了配置中心,然后啟動(dòng)客戶端,

發(fā)現(xiàn)打印的日志是這樣的

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)

從日志上看,已經(jīng)獲取到了配置中心的配置,但是呢,總感覺日志不對(duì),怎么就沒有啟動(dòng)的端口呢。

springcloud經(jīng)常會(huì)一個(gè)模塊包含另外模塊,難道web模塊沒有被 spring-cloud-starter-config 包含?

那就加入web模塊吧

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
 </dependency>

加入之后再啟動(dòng)項(xiàng)目

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)

果然,從配置中心拉取到了配置并成功啟動(dòng)了。

spring cloud配置中心客戶端配置的坑

1. 出錯(cuò)信息如下

在啟動(dòng)配置中心的客戶端時(shí),報(bào)以下錯(cuò)誤信息:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'foo' in value "${foo}"

2. 度娘查了下,發(fā)現(xiàn)很多人碰到這個(gè)坑

首先我提交到git上到配置文件名稱為下面兩個(gè)文件

cloud-config-dev.properties
cloud-config-test.properties

遵循配置中心配置文件的規(guī)則/{application}-{profile}.properties

所以在cloud-config-client端調(diào)用的時(shí)候,applcation.name應(yīng)該是cloud-config,然而我在配置的時(shí)候,想當(dāng)然的寫成了cloud-config-client,導(dǎo)致出現(xiàn)上面的錯(cuò)誤。

解決方法很簡(jiǎn)單,貼下client的配置如下

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Java進(jìn)行Appium自動(dòng)化測(cè)試的實(shí)現(xiàn)

    Java進(jìn)行Appium自動(dòng)化測(cè)試的實(shí)現(xiàn)

    這篇文章主要介紹了Java進(jìn)行Appium自動(dòng)化測(cè)試的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01
  • 使用@RequestBody傳遞多個(gè)不同對(duì)象方式

    使用@RequestBody傳遞多個(gè)不同對(duì)象方式

    這篇文章主要介紹了使用@RequestBody傳遞多個(gè)不同對(duì)象方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-10-10
  • Java學(xué)習(xí)-打印1-1000以內(nèi)的水仙花數(shù)代碼實(shí)例

    Java學(xué)習(xí)-打印1-1000以內(nèi)的水仙花數(shù)代碼實(shí)例

    這篇文章主要介紹了Java打印1-1000以內(nèi)的水仙花數(shù),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • Java中的Static class詳解及實(shí)例代碼

    Java中的Static class詳解及實(shí)例代碼

    這篇文章主要介紹了 Java中的Static class詳解及實(shí)例代碼的相關(guān)資料,在Java中我們可以有靜態(tài)實(shí)例變量、靜態(tài)方法、靜態(tài)塊。類也可以是靜態(tài)的,需要的朋友可以參考下
    2017-03-03
  • SpringBoot攔截器使用精講

    SpringBoot攔截器使用精講

    攔截器可以根據(jù) URL 對(duì)請(qǐng)求進(jìn)行攔截,主要應(yīng)用于登陸校驗(yàn)、權(quán)限驗(yàn)證、亂碼解決、性能監(jiān)控和異常處理等功能上。SpringBoot同樣提供了攔截器功能。 本文將為大家詳細(xì)介紹一下
    2021-12-12
  • MyBatis-Plus?條件查詢器的實(shí)現(xiàn)

    MyBatis-Plus?條件查詢器的實(shí)現(xiàn)

    本文主要介紹了MyBatis-Plus?條件查詢器的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07
  • SpringBoot執(zhí)行異步任務(wù)Async介紹

    SpringBoot執(zhí)行異步任務(wù)Async介紹

    這篇文章主要為大家介紹了SpringBoot執(zhí)行異步任務(wù)Async示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-09-09
  • springboot整合mybatis流程詳解

    springboot整合mybatis流程詳解

    這篇文章主要為大家詳細(xì)介紹了springboot整合mybatisplus的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助
    2022-05-05
  • Eclipse中改變默認(rèn)的workspace的方法及說明詳解

    Eclipse中改變默認(rèn)的workspace的方法及說明詳解

    eclipse中改變默然的workspace的方法有哪幾種呢?接下來(lái)腳本之家小編給大家介紹Eclipse中改變默認(rèn)的workspace的方法及說明,對(duì)eclipse改變workspace相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧
    2016-04-04
  • SpringBoot+RabbitMQ+Redis實(shí)現(xiàn)商品秒殺的示例代碼

    SpringBoot+RabbitMQ+Redis實(shí)現(xiàn)商品秒殺的示例代碼

    本文主要介紹了SpringBoot+RabbitMQ+Redis實(shí)現(xiàn)商品秒殺,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-11-11

最新評(píng)論