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

2018年07月23日 16:33:25
一颗很菜的菜
阅读数 5907

版权声明:本文为博主原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接和本声明。

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接口,访问可以参照以下的规则:

//[/]:

~: /-.yml
~: //-.yml
~: /-.properties
~: //-.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;否则程序启动不起来。

最新文章

  1. 小的div在大的div中垂直居中
  2. WPF学习之路(十)实例:用户注册
  3. C语言中#define的用法(转)
  4. java发送短信--httpclient方式
  5. Javascript中理解发布--订阅模式
  6. spring data redis使用示例
  7. latin1字符集在navicat下显示乱码(mysql)
  8. Nginx配置免费SSL证书StartSSL,解决Firefox不信任问题
  9. [Protractor] Getting Started With Protractor
  10. BC 2015在百度之星程序设计大赛 - 预赛(1)(系列转换-二分法答案贪婪)
  11. CSS3实战开发: 纯CSS实现图片过滤分类显示特效
  12. $_SERVER参数的含义
  13. 【Java基础】Java类的加载和对象创建流程的详细分析
  14. Vc数据库编程基础1
  15. 001_自定义过滤及添加文件内容脚本(nginx)
  16. Laravel自定义 封装便捷返回Json数据格式引用
  17. 论文阅读-使用隐马模型进行NER
  18. 隐藏linux软件及内核版本
  19. 汇编 AND 运算
  20. winform中RichTextBox在指定光标位置插入图片

热门文章

  1. exe4j 打包(多个jar打包)
  2. sql (12) HAVING
  3. Windows 关闭win32 控制台
  4. 1001CSP-S模拟测试赛后总结
  5. 概率dp——hdu4089推公式+循环迭代
  6. spring中使用RabbitMQ
  7. 云-腾讯云-笔记:pom.xml 配置
  8. (15)python打包
  9. mysql用户管理和pymysql
  10. Python collection模块与深浅拷贝