Search code examples
javaspringspring-cloudspring-cloud-config

How to configure a custom RestTemplate when using spring-cloud-config-client?


I am trying to use spring-cloud-config-client to read my configuration properties from a spring-cloud-config-server application on startup. My application is a Spring-Boot application and what I need to do is adding a specific header to the request before it is sent to the config server.

I have read the documentation (http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html) and I can't find any way to customize the ConfigServicePropertySourceLocator with a provided RestTemplate.

What would be the best way to do that?

Many thanks


Solution

  • There is a ConfigServicePropertySourceLocator.setRestTemplate(). In you configuration class add a @PostConstruct method where you could set your RestTemplate there.