在JavaEE系统中,我们会经常用到定时任务,下面是我自己写的一个demo.
前面几篇quartz博客感觉看的还是难懂 于是重新整理下
源码地址:
1.所需要的jar
使用maven的pom.xml如下
commons-logging commons-logging 1.2 log4j log4j 1.2.17 org.quartz-scheduler quartz 2.2.2 org.slf4j slf4j-api 1.7.21 org.slf4j slf4j-log4j12 1.7.21 org.springframework spring-aop 4.3.2.RELEASE org.springframework spring-beans 4.3.2.RELEASE org.springframework spring-context 4.3.2.RELEASE org.springframework spring-context-support 4.3.2.RELEASE org.springframework spring-core 4.3.2.RELEASE org.springframework spring-expression 4.3.2.RELEASE org.springframework spring-tx 4.3.2.RELEASE org.springframework spring-web 4.3.2.RELEASE
2.实体bean
package com.shanheyongmu.quartz;import java.util.Date;public class Study { public void doStudy(){ System.out.println("It is"+new Date()); } }
3.applicationContext.xml
4.web.xml
contextConfigLocation /WEB-INF/classes/applicationContext.xml
classpath*:applicationContext.xml
org.springframework.web.context.ContextLoaderListener
http://cron.qqe2.com/ 这个是在线quartz时间格式的网站