【问题标题】:Spring cloud config server not loading the properties filesSpring Cloud 配置服务器未加载属性文件
【发布时间】:2015-06-18 18:36:00
【问题描述】:

我正在尝试使用这个示例 spring 云配置服务器应用程序 https://github.com/spring-cloud-samples/configserver,但它在我的本地“windows 7”机器上没有按预期工作。

当我尝试访问 http://localhost:8888/foo/development 时,我得到的结果如下,没有任何属性

{
  "name": "foo",
  "profiles": [
    "development"
   ],
  "label": "master",
  "propertySources": [
  ]
}

下面是一些与属性文件加载相关的日志

2015-04-13 17:46:03.381 调试 6684 --- [nio-8888-exec-1] osccsNativeEnvironmentRepository:不添加属性源:file:/C:/Users/sekhap/git/configserver/target /config/foo-development.properties
2015-04-13 17:46:03.382 调试 6684 --- [nio-8888-exec-1] osccsNativeEnvironmentRepository:不添加属性源:file:/C:/Users/sekhap/git/configserver/target/config/ foo.properties
2015-04-13 17:46:03.382 调试 6684 --- [nio-8888-exec-1] osccsNativeEnvironmentRepository:不添加属性源:file:/C:/Users/sekhap/git/configserver/target/config/应用程序.yml

为什么没有加载属性?与 Windows 环境有什么关系,因为 C: 前面有“/”?

【问题讨论】:

  • 我在 Ubuntu 中运行了配置服务器,一切正常。这一定是仅在 Windows 中的问题。 stackoverflow.com/questions/29922871/…
  • 在windows中同样的问题,但在linux中运行时工作正常

标签: spring-boot spring-cloud


【解决方案1】:

这是当前发布版本 (1.0.1.RELEASE) 中的一个错误,已在当前快照 (1.0.2.BUILD-SNAPSHOT) 中修复。

检查是否应包含配置的代码未规范化文件路径,因此在 Windows 上运行时失败,因为文件路径有 Windows 分隔符(“\”)并且它比较的路径有 linux 分隔符("/")。

【讨论】:

    猜你喜欢
    • 2015-01-03
    • 2016-01-17
    • 2020-11-25
    • 2015-07-13
    • 2016-02-07
    • 2016-11-26
    • 2019-07-29
    • 1970-01-01
    • 2021-03-29
    相关资源
    最近更新 更多