Spring config server read proterties from local machine if fetch data from git repositories failed

时间:2018-10-09 06:52:58

标签: git spring-boot spring-cloud-config spring-properties spring-boot-configuration

I am new for spring config server. I want to implement spring config server from my application where my config server fetch properties details from git repositories but in case of my git server are not able to respond, how can I read properties from my local machine?

Note: I want to read properties from my local machine only in case my git server are not able to respond.

1 个答案:

答案 0 :(得分:0)

您可以按照存储库的以下配置进行操作。

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/your-repository/config-repo
          repos:
            local:
              pattern: local*
              uri: file:/home/your-directory/config-repo
  1. 本地存储库将匹配所有配置文件中以本地开头的所有应用程序名称。
  2. 如果在所有配置文件中您的应用程序名称与 local 都不匹配,则默认情况下将替换URI spring.cloud.config.server.git.uri 值。

这里是config-server-multiple-repositories的相关文档。