2017-10-17 42 views
0

我已經創建了使用以下站點的客戶端。我們不允許使用嵌入式tomcat,所以戰爭部署在tcServer中。客戶端中的方法需要安排。所有的方法都在SpringBootApp中。如何安排每15分鐘運行一次客戶端。SpringBoot:-Scheduling RestClient方法

有人可以指導我如何做到這一點?

RestClient Code

回答

0

調度是很容易的。不管你是否使用嵌入式tomcat。你有SpringBoot,這就夠了。配置計劃方法的步驟:

  1. 在您的配置類或甚至@SpringBootApplication旁邊添加@EnableScheduling註釋。
  2. 創建調度類,這將觸發在時間間隔的方法是這樣的:

    @Service public class MyScheduler { @Scheduled(cron = "* */15 * * * *") void someMethod() { // do stuff here } }

的Cron表達式進行了說明:https://stackoverflow.com/a/26147143/7866105

教程:
https://spring.io/guides/gs/scheduling-tasks/http://www.baeldung.com/spring-scheduled-tasks