定时任务spring-task

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yuynim/article/details/79384965

配置文件:

	<!-- 定时任务要执行的方法 -->
	<bean id="taskTest" class="com.xxx.task.TaskTest" />

	<!--用于定时任务的执行 -->
	<task:scheduled-tasks>
		<!-- 指定要运行的类的方法,每1分钟执行一次 -->
		<!--<task:scheduled ref="taskTest" method="taskMethod" cron=" 0 */1 * * * ?" />-->
		<!-- 指定要运行的类的方法,每天8点执行一次 -->
		<task:scheduled ref="taskTest" method="taskMethod" cron=" 0 0 8 * * ?" />
	</task:scheduled-tasks>

代码:

public class TaskTest{
   public void taskMethod(){....}
}

猜你喜欢

转载自blog.csdn.net/yuynim/article/details/79384965