Anotar a Classe com
@Component
=========================================================
Anotar o método com
@Scheduled(cron = "* * 0 * * ?")
cron = segundos, minutos, hora, dia, mês
cron = "* * 0 * * ?" -> meia noite
cron = "*/5 * * * * ?" -> a cada 5 segundos
cron = "* 2/5 * * * ?" -> apartir do segundo minuto a cada 5 minutos
cron = "5 30 5 * * ?" -> 5:30:05 AM
=========================================================
Incluir no context do spring
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd"
>
<task:annotation-driven/>
...
</beans>
========================================================
Fonte: http://howtodoinjava.com/2013/04/23/4-ways-to-schedule-tasks-in-spring-3-scheduled-example/
Nenhum comentário:
Postar um comentário