How to Schedule a Java Function having Parameters in Spring Boot?

Viewed 24

I have to call a specific function after every 24 hours, For that purpose i tried all the possible ways such as Timers, and Scheduled Annotation etc but they only works for functions with no parameters and with no return. Is there any possible way to Schedule a parameterized Function? Thanks.


For Example

Controller Class:

public class MyController
{
    
    @Scheduled(cron = "0/20 * * * * ?")
    public String Run24(String access_token)
    {
       //doing something
        return "";
    }
}

Main Class:

@SpringBootApplication
@EnableScheduling

public class WithingsApplication {


    public static void main(String[] args) throws NoSuchAlgorithmException, InvalidKeyException {
        SpringApplication.run(WithingsApplication.class, args);

    }

}

======================================

0 Answers
Related