Spring Boot: Using a @Service in Quartz job execution

前端 未结 2 1132
时光取名叫无心
时光取名叫无心 2021-02-06 01:49

In an application, since I converted it from a classical Spring webapp (deployed in a system Tomcat) to a Spring Boot (V1.2.1) application I face the problem that the Quartz-bas

2条回答
  •  甜味超标
    2021-02-06 02:16

    My answer not fully matches to you question, but Spring expose you another ability - to start cron-expression based scheduler on any service.

    Using Spring.Boot you can configure your application to use scheduler by simple placing

    @EnableScheduling
    public class Application{
    ....
    

    After that just place following annotation on public(!) method of @Service

    @Service
    public class MyService{
    ...
        @Scheduled(cron = "0 * * * * MON-FRI")
        public void myScheduledMethod(){
        ....
        }
    

提交回复
热议问题