Spring 中的后台作业支持
Background job support in Spring
我正在寻求 Spring 的支持以执行后台作业。我想在后台触发我的应用程序和 运行 的作业,而不妨碍应用程序的执行。我该怎么做?
参见上面的 hasnae 中的 link。在 Java 配置中,您可以执行以下操作:
@EnableScheduling
@Configuration
public class BackgroundTaskScheduler {
@Autowired
private BackgroundTaskBean backgroundTaskBean;
@Scheduled(cron = "${property.cronStatement}")
public void backgroundTaskOne() {
backgroundTaskBean.runTask();
}
}
我正在寻求 Spring 的支持以执行后台作业。我想在后台触发我的应用程序和 运行 的作业,而不妨碍应用程序的执行。我该怎么做?
参见上面的 hasnae 中的 link。在 Java 配置中,您可以执行以下操作:
@EnableScheduling
@Configuration
public class BackgroundTaskScheduler {
@Autowired
private BackgroundTaskBean backgroundTaskBean;
@Scheduled(cron = "${property.cronStatement}")
public void backgroundTaskOne() {
backgroundTaskBean.runTask();
}
}