zoukankan      html  css  js  c++  java
  • Spring Cloud Config-Client 无法获取 Config-Server 在 github 上的配置文件的属性值,竟然是因为

    Spring Cloud Config-Client 无法获取 Config-Server 在 github 上的配置文件的属性值,竟然是因为!!!

    版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
    本文链接:https://blog.csdn.net/true1cc/article/details/81170079

    Spring Cloud Config-Server 配置中心 配置文件放在github,配置文件均为bootstrap.yml(bootstrap.yml的优先级级比application.yml高,所以会先去github配置中心获取信息)

    运行 Spring Cloud Config-Client 应用程序时,报错信息如下:

    1. java.lang.IllegalArgumentException: Could not resolve placeholder 'from' in value "${from}"
    2. at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    3. at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    4. at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    5. at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    6. at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    7. at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:839) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    8. at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1086) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    9. at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    10. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    11. at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    12. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    13. ... 17 common frames omitted

    !!!原因!!!

    github上的配置文件的名字构成必须是: {application}-{profile}.properties

    仓库中的配置文件会被转换成web接口,访问可以参照以下的规则:
    

    /{application}/{profile}[/{label}]:

    ~: /{application}-{profile}.yml
    ~: /{label}/{application}-{profile}.yml
    ~: /{application}-{profile}.properties
    ~: /{label}/{application}-{profile}.properties

    比如:config-client的配置文件信息如下:

    1. eureka:
    2. client:
    3. serviceUrl:
    4. defaultZone: http://peer1:1122/eureka/
    5. spring:
    6. application:
    7. name: config-client
    8. cloud:
    9. config:
    10. uri: http://localhost:9200/
    11. label: master
    12. profile: dev
    13. server:
    14. port: 9300
    那么在github中的配置文件名必须是:config-client-dev.properties;否则程序启动不起来。
    

    00

  • 相关阅读:
    网页链接在 什么时候 进行跳转到哪里?
    word中那些重要但是被人忽略的快捷键和长word文档的跳转
    如何在editplus中配置ctags?
    winsow xp不能安装软件, 提示"中断" 是因为设置了 软件限制策略
    firefox的plugin-container.exe进程如何关闭?
    thinkphp的url地址区分大小写?
    thinkphp单入口和多入口的访问方法
    什么时候使用tab键来对齐代码和代码的风格
    该不该用inline-block取代float? inline和float的区别?
    cad中关于点样式点的绘制
  • 原文地址:https://www.cnblogs.com/jpfss/p/11357624.html
Copyright © 2011-2022 走看看