Spring Cloud Config Server – SearchPaths

In this short tutorial, you will learn how to use SearchPaths to configure your Spring Cloud Config Server to discover properties files in remote Git repository subdirectories.

To learn how to configure Spring Cloud Config Server and also Spring Cloud Config Client, please read this tutorial:

For a step-by-step series of video lessons, please check this page: Spring Boot Microservices and Spring Cloud.

Using SearchPaths

By default, Spring Cloud Config Server will look for property files in a root folder of your remote Git repository. You can use SearchPaths to specify which additional folders in a Git repository should be checked for property files. For example:

server.port=8012
spring.application.name=PhotoAppAPIConfigServer


spring.cloud.config.server.git.uri = https://github.com/<YOUR USER GIT HUB NAME HERE>/<REPOSITORY NAME HERE>
spring.cloud.config.server.git.username = 
spring.cloud.config.server.git.password = 
spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.searchPaths=search-feature-properties, shopping-card*

Where: 

  •  search-feature-properties – is a folder name which holds application.properties file with properties related to Search Feature,
  •  shopping-card* – will match all folders that begin with shopping-card prefix. This will make Spring Cloud Config Server to check folders like
    • shopping-card-mobile
    • shopping-card-tv

You can thus have the following folder structure in your Git repository

/application.properties
/search-feature-properties/application.properties
/shopping-card-tv/application.properties

I hope this very short tutorial on how to use SearchPaths configuration property in Spring Cloud Config Server was helpful to you. Please check other Spring Cloud related tutorials on this site to learn more. And if you enjoy learning Spring Boot by watching a series of step-by-step video tutorials, please have a look at the below list of video courses. One of them might greatly help you improve your RESTful Web Services developer skills.


Leave a Reply

Your email address will not be published. Required fields are marked *