繁体   English   中英

Spring Cloud Native Config Server未选择yml文件

[英]Spring Cloud Native Config Server not picking yml files

我的Spring Cloud配置服务器未从类路径中选择yml文件

    spring:
  profiles:
    active: native
  cloud:
    config:
      server:
       native:
            search-locations: file:///C:/Users/Arun/git/MicroService_sample/config-server/src/main/resources/application-local.yml

低于result,即使我使用search-locations: classpath:/configserver-local.yml ,结果也保持不变search-locations: classpath:/configserver-local.yml

结果

  {"name":"configserver","profiles":["local"],"label":null,"version":"d1da013b1365b9001a5609e12c8590c875d782f4","state":null,"propertySources":[]}

端点: http:// localhost:8080 / configserver / local

而且在应用程序启动时我找不到用于选择yml文件的任何日志

尝试修改您的搜索位置地址

我尝试将文件放在.yml的D盘中,如下所示

spring:
  profiles:
    active: native
  cloud:
    config:
      server:
       native:
            search-locations: D:/

并在D:\\ configserver-local.yml中包含内容的文件

test: 1233333

当我访问http:// localhost:8080 / configserver / local时,结果是预期的

{"name":"configserver","profiles":["local"],"label":null,"version":null,"state":null,"propertySources":[{"name":"file:D:/configserver-local.yml","source":{"test":1233333}}]}

在Windows上以绝对路径在纯模式下设置此搜索位置时,我也遇到很多麻烦。

最后,经过大量研究和尝试,我选择将配置文件直接集成到src / main / resources文件夹中的“ config”文件夹中的config-server类路径中。

由于“本机”模式可能仅用于开发和测试环境(对于生产环境,我将使用普通模式,该模式读取的是Git存储库,而不是本地硬盘驱动器),因此对我来说还可以。

您已经按照文档中的内容进行操作(由于在Windows上,因此需要在“文件”之后加3 / )。 对我来说唯一可行的替代方法是使用user.home目录,但是我不希望使用该目录,因此我将属性文件放在src / main / resources / config文件夹中。

user.home目录的语法:

spring.cloud.config.server.native.searchLocations=file:///${user.home}/Downloads/config-folder

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM