I\'m setting up a scheduled tasks scheme in spring, using the task namespace.
I want to schedule most tasks to fire according to a cron expression, and some to fire
If you don't need an initial delay, you can make it run 'just once' on startup as follows:
(Of course, if you think your code is going to run for longer than 3E8 years, you may need a different approach...)
If you need an initial delay, you can configure it as follows (I'm testing with Spring 3.1.1) - this doesn't require any additional dependencies and you don't have to write your own trigger, but you do have to configure the PeriodicTrigger provided by Spring:
Spring 3.2 appears to support the "initial-delay" attribute directly, but I haven't tested this; I'd guess this works: