When I was working on a Spring Boot application that used scheduling and acted as a config client, I was unable to pull the crontab expression from the application-cloud.yml file.
This:
@Scheduled(cron = "${cron.expression}")
did not work.
Putting the cron.expression in the jar's internal application.yml was not an option. As a workaround, I changed the source of that property to the appropriate environment variable, CRON_EXPRESSION
.
Does anyone know why I had to do that? Why was Spring Scheduled unable to resolve an externalized configuration property?
Edit:
Here is the bootstrap.yml
that the project was setup with:
spring:
profiles: cloud
application:
name: application-name
cloud:
config:
uri: https://config-server.com
fail-fast: false