Reputation: 121
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.
Step 1: Update the config file and start cloud config server. Able to
see config http://localhost:8888/hello-world/default
Step 2: Start client app hello-world
, client app able to read the
test
property file from cloud config server.
Step 3: Make changes to config by updating test: Good Bye
on
hello-world.yaml.
At this moment, if I check
http://localhost:8888/hello-world/default
,it still shows old value.
Step 4: Run /actuator/refresh
on client app. But it won't detect
any change on 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
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,
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
spring.cloud.config.server.native.searchLocations
either with full directory path or just directory from app running locationExamples
For full path in windows use file:///full-path
spring.cloud.config.server.native.searchLocations: file:///E:\configs
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
we can configure multiple locations too as follows, spring.cloud.config.server.native.searchLocations: file:///E:\configs, configs
Upvotes: 1