Reputation: 33
I have several Spring Boot REST services that pull in properties from a Spring Cloud Config server. Let's say the application is called ApplicationName. In that case, the properties files are called ApplicationName.properties, ApplicationName-test.properties, etc. If I update one of those files and trigger the /actuator/refresh endpoint, it doesn't update the properties in the service. It just returns:
[
"config.client.version"
]
indicating it detected a change, but it did not detect the specific value that changed.
Previously, I used Spring Boot 2.3.x and this all worked perfectly. Once I updated to Spring Boot 2.6.x, it stopped working. I just updated to Spring Boot 2.7.1 and it's still not working.
However, if I have properties in a file called application.properties hosted on the same Spring Cloud Config server and I update that one, the refresh endpoint works fine.
I have the Config class annotated with @RefreshScope.
I have the following in my application.yml:
management:
endpoints:
web:
exposure:
include: refresh
endpoint:
refresh:
enabled: true
I have the following in the bootstrap file:
spring.cloud.config.uri=https://spring-cloud-config.domain.com
spring.cloud.config.name=${spring.application.name}
I'm using Spring Boot version 2.7.1 and Spring Cloud Version 2021.0.3.
It seems like there's a setting I'm missing to tell the refresh actuator to check the ${spring.application.name}.properties file in addition to the default application.properties file. Any idea what that setting might be?
Update: I tried putting the config files in a subdirectory in Bitbucket where the Spring Cloud Config server pulls from. The subdirectory is the name of the application, and the config files inside are named application.properties. The application reads them in fine, but the refresh doesn't work for those either. It seems to only work for files named application.properties that reside in the root directory.
Upvotes: 1
Views: 2428
Reputation: 33
It looks like the following no longer works in the bootstrap.properties file:
spring.cloud.config.name=${spring.application.name}
It allows the properties to load when the service starts, but it does not allow the properties to be refreshed. I was able to get it working by specifying the actual application name:
spring.cloud.config.name=MyApplicationName
Upvotes: 1