Spring云配置服务器未加载属性文件

时间:2015-04-13 12:37:03

标签: spring-boot spring-cloud

我尝试使用此示例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 DEBUG 6684 --- [nio-8888-exec-1] osccsNativeEnvironmentRepository:不添加属性源:file:/ C:/ Users / sekhap / git / configserver / target /config/foo-development.properties
  2015-04-13 17:46:03.382 DEBUG 6684 --- [nio-8888-exec-1] osccsNativeEnvironmentRepository:不添加属性源:file:/ C:/ Users / sekhap / git / configserver / target / config / foo.properties
  2015-04-13 17:46:03.382 DEBUG 6684 --- [nio-8888-exec-1] osccsNativeEnvironmentRepository:不添加属性源:file:/ C:/ Users / sekhap / git / configserver / target / config / application.yml

为什么属性没有加载?是否与Windows环境有关,因为" /"在C面前:?

1 个答案:

答案 0 :(得分:2)

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

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