1

I want to use java expression inside cron for scheduling in Spring Boot.

@Scheduled(cron = "${FileConfig.FileEnum.getScheduleTime()}" )
public void scheduleFetchFiles() {

...//method body

}

Is there a direct way to use pojo object or enum value in cron?

1 Answer 1

0

It seems you just want any way to inject the value. You are betting of just setting it via property than the return value of a method.

@Scheduled(cron = "${scheduledTimes.cron}")
public void scheduleFetchFiles() {

...//method body

}

Where scheduledTimes.cron is specified in your properties.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.