java - Spring Cloud Native Config Server不选择yml文件

标签 java spring-cloud spring-cloud-config

我的Spring云配置服务器没有从类路径中选取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

得到以下结果,即使我使用 search-locations: classpath:/configserver-local.yml

结果

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

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

我没有找到任何在应用程序启动时选择 yml 文件的日志

最佳答案

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

我尝试将文件放入 D 盘,其中包含 .yml,如下所示

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}}]}

关于java - Spring Cloud Native Config Server不选择yml文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55583784/

相关文章:

java - 当 Spring Security 在 Spring Cloud Config Server 上处于 Activity 状态时,Spring Cloud Config Client 未获取配置

java - 普通多态性和使用泛型的多态性有什么区别?

spring-cloud - 如何使用swagger-codegen-maven-plugin生成spring cloud feign客户端

java - Spring Cloud ;云类型转换; spring.jpa 属性

java - 尝试使用 ssh 私钥文件设置 Spring Boot 云配置服务器并获取 : ucom. jcraft.jsch.JSchException:USERAUTH 失败

spring-boot - Git 上的 Spring Boot 配置

java - Android如何在按下主页按钮时终止进程

java - 更改上游项目中的速度日志文件位置

java - 通过自定义 Spring validator 处理绑定(bind)到输入字段的长值是否太晚了?

java - 如何设置 RestTemplate 以重试对某些响应状态代码的调用?