Shebang_John
Shebang_John

Reputation: 121

Spring Cloud Config Server Not picking changes

I am trying to setup spring config cloud using local file system.

Below is my config on cloud server.

server.port=8888
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=classpath:/

Bootstrap.properties on client app is as shown below

spring.application.name=hello-world
spring.cloud.config.uri=http://localhost:8888
management.endpoints.web.exposure.include=*

I have also created hello-world.yml on class path for the hello-world spring boot application with property, test: Hello World

Followed below steps to make use of config server.

The new changes are reflected only if I restart the cloud config server. Is there any configuration issue causing the cloud config server to unable to listen to changes ?

I could see o.s.cloud.commons.util.InetUtils : Cannot determine local hostname INFO log on cloud config app.

Upvotes: 2

Views: 3622

Answers (1)

mramsath
mramsath

Reputation: 807

First of all I followed the same exact steps you followed and got the same issue, after almost day of search and study on the matter found out the followings,

  1. we shouldn't use classpath:/<whatever> for spring.cloud.config.server.native.searchLocations because when we use so and build the project and run the location refers to the directory inside the generated .jar file, so we will not be able to update it in runtime.

To confirm this you can stop config server, open you .jar archive and delete hello-world.yml file then try http://localhost:8888/hello-world/default you will get default null responses

  1. So we have to use some other locations for spring.cloud.config.server.native.searchLocations either with full directory path or just directory from app running location

Examples

  1. For full path in windows use file:///full-path spring.cloud.config.server.native.searchLocations: file:///E:\configs

  2. Just for a directory (which will search project root directory if you running from IDE, if running jar then target directory or jar location spring.cloud.config.server.native.searchLocations: configs spring.cloud.config.server.native.searchLocations: configs\whatever

  3. we can configure multiple locations too as follows, spring.cloud.config.server.native.searchLocations: file:///E:\configs, configs

Upvotes: 1

Related Questions