Spring Boot Actuator refresh not working for Spring Cloud updates to ${spring.application.name}.properties files - spring

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.

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

Related

Additional config file with Spring boot cloud config

I have a requirement to split application properties into 2. Some viewable from cloud and some hidden and specified by file on a Rancher environment.
When running locally the default config file successfully honors spring.config.import property which points to a different file.
When fetching the configs from cloud it seams the spring.config.import property is completely ignored and the additional file doesn't get loaded or even checked for.
It there a way to achieve this requirement? Even if different from using the spring.config.import property.
I have upgraded from Spring 2.1.7 to 2.7.7 to be able to use the latest application config loading.

Spring boot sleuth no traces in zipkin

we are trying to use sleuth to send logs to zipkin. We are using spring boot '2.2.6.RELEASE' and cloud version Hoxton.RELEASE. I have added below dependencies
implementation "org.springframework.cloud:spring-cloud-starter-zipkin:2.2.6.RELEASE"
implementation "org.springframework.cloud:spring-cloud-starter-sleuth:2.2.6.RELEASE"
implementation "org.springframework.cloud:spring-cloud-sleuth-zipkin:2.2.6.RELEASE"
And added below props in logback.xml
[%X{traceId} %X{spanId} %X{X-Span-Export}]
With the above changes in our 2 services, we were expecting zipkin will have some logs, but nothing appeared. So then we tried to add below properties in application.properties
spring.zipkin.base-url=http://localhost:9411
spring.zipkin.enabled=true
spring.zipkin.service.name=xyz-service
spring.sleuth.enabled=true
spring.sleuth.integration.enabled=true
spring.sleuth.sampler.rate=100
spring.sleuth.sampler.probability=1.0
spring.zipkin.sender.type=web
And still dont see logs / service name in zipkin.
Can you see what am I doing wrong here. Out apps have cloud-stream dependencies as well. And also noted that in logs I am getting X-span-export coming as false. For ex: [3e205e41db60212f 77a405a53d62c9fa false]
Please upgrade the project to the latest version of Spring Boot and Spring Cloud. Also use the BOM as the source of versions - do not set them manually. Please do not set the default properties manually cause as defaults they are already set.

Spring cloud config server not honoring logging.file property and not logging external file

I'm using spring-boot-starter 2.3.3.RELEASE version. I'm running my spring cloud configuration server in native profile (looking for configuration files in file system). I added
logging.file = /var/log/config.log in application.properties file. But my application is not logging logs to this file.(All other microservices are logging to this location). Am I missing any additional settings for Spring cloud config server? Thank you so much for your help.
In the spring boot 2.3.3 RELEASE documentation the logging properties that specify where the location should be is indicated using the property:
logging.file.path={path}
The documentation:
https://docs.spring.io/spring-boot/docs/2.3.3.RELEASE/reference/htmlsingle/#boot-features-logging-file-output
This modification from logging.path to logging.file.path appears as a deprecation in Spring Boot 2.2:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.2-Release-Notes#deprecations-in-spring-boot-22
One way to do it with spring-boot application is, setting it from command line argument as default it will dump every thing on console.
logging.file=logs/test.log
Old school but far effective, save path in application.properties
logging.file=logs/test.log

Passing configuration from yaml file to spring boot application without rebuilding it

How to pass configuration through yaml file to a running spring boot application so that there is no need of rebuilding the application and changes are reflected while the application is runnig?
I think this can help you:
How to hot-reload properties in Java EE and Spring Boot?
Take a look at Spring Boot Cloud Config. It allows you to manage your config files centralized and has the ability to push new configurations to the connected applications.

Spring Boot - ignore application.yml / bootstrap.yml inside .jar file

I have a spring cloud application using config server for fetching configuration. We are using Spring Boot 1.5.4 & Spring Cloud Dalston.SR2.
For deployment purposes we are providing external bootstrap.yml file and specifying its location with spring.cloud.bootstrap.location parameter.
We already had some struggle with the fact that, for couple of properties, service fell back to .jar's bootstrap.yml / application.yml
The only way I could find to solve that, was changing name of external configuration files with spring.config.name and spring.cloud.bootstrap.name. Then, the original names from .jar won't be matched and taken under consideration.
Is there are other way to tackle that?
You could solve that by upgrading to Spring Boot 2.x because they fixed the behavior of spring.config.location (see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide#configuration-location) which also affects spring.cloud.bootstrap.location in the same way
See also that question Different behavior of spring.cloud.bootstrap.location since Spring Boot 2

Resources