我已经设置了一个Spring Scheduler服务,该服务按预期在本地服务器上运行。但是,当我将其部署到heroku服务器时,调度程序服务未运行。

以下是主要服务:

@Configuration
@SpringBootApplication(scanBasePackages = {"com.spring.test"})
@EnableScheduling
public class SpringTest{

    public static void main(String[] args) {
        SpringApplication.run(SpringTest.class, args);
    }
}


调度方法如下:

@Service
@Component
public class ScheduledTasks {
     @Scheduled(fixedRate = 900000)
     public void reminderScheduler() {
        //some tasks will execute here...
     }
}

最佳答案

您的配置看起来不错,您需要在类ScheduledTasks中进行更多登录,只是为了确保即将发生什么异常(如果有)。在这种情况下,Spring Scheduler应该可以工作。

10-04 19:03