简体   繁体   English

如何在Java Spring中运行预定作业?

[英]How to run scheduled job in java spring?

I use 我用

 CommandLineJobRunnerWrapper

as main class. 作为主要课程。 For run job use 用于运行作业

SimpleJobLauncher

for execute job one time. 一次执行作业。 How I could schedule it to execute eg each day at 10 o'clock? 我如何安排它每天10点执行? Because now application immedeately exit after method execute finished. 因为现在应用程序在方法执行完成后立即退出。 I have tried use spring scheduler but without success. 我曾尝试使用Spring Scheduler,但没有成功。

You could just use the Scheduled annotation 您可以只使用Scheduled注释

@Scheduled(cron="0 0 10 * * MON-FRI")

on your method. 根据您的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM