一个简单的Quartz定时任务
Posted chuluofanchen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一个简单的Quartz定时任务相关的知识,希望对你有一定的参考价值。
package com.shuadan.quartz; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component public class GlodQuartz { /** * 每隔2秒执行 */ @Scheduled(cron = "*/2 * * * * ? ") public void addUserGold() { System.out.println("搞事情?"); } }
springMVC-mvc.xml添加配置声明
xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation=" http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"
<task:annotation-driven /> <context:component-scan base-package="com.shuadan.quartz"/>
以上是关于一个简单的Quartz定时任务的主要内容,如果未能解决你的问题,请参考以下文章