简体   繁体   中英

How do I maintain values between spring task scheduled

I want to maintain values between the spring task:scheduled, example my cron is to trigger every one hour.

<task:scheduled-tasks>
<task:scheduled ref="runScheduler" method="run" cron="0 0 * * * *" />
</task:scheduled-tasks>

I want to know, How do I get the value from last hour cron thread on next cron thread.

Cron attribute is used with @Scheduled annotation. Value of this attribute must be a cron expression.This cron expression will be defined in a properties file and key of related property will be used in @Scheduled annotation.

<task:scheduled-tasks>
<task:scheduled ref="runScheduler" method="run" cron="#{applicationProps['cron.expression']}" />
</task:scheduled-tasks>

Then use @Scheduled(cron = "${cron.expression}") annotation.

Following link might help you:

http://howtodoinjava.com/spring/spring-core/4-ways-to-schedule-tasks-in-spring-3-scheduled-example/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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