按照nutzbook做的,但是没有出效果,以下是我的配置
#cron.properties
cron.edu.taru.quartz.job.TestJob=0 0/2 * * * ?
#quartz.properties
org.quartz.scheduler.instanceName = ProjectScheduler
org.quartz.threadPool.threadCount = 3
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
org.quartz.scheduler.skipUpdateCheck=true
package edu.taru.quartz.test;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Scheduler;
@IocBean
public class TestJob implements Job {
@Inject Scheduler scheduler;
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("_________________________________");
System.out.println("______________定_________________");
System.out.println("______________时_________________");
System.out.println("______________器_________________");
System.out.println("______________OK_________________");
System.out.println("______________!_________________");
System.out.println("_________________________________");
}
}
package edu.taru;
import org.nutz.dao.Dao;
import org.nutz.dao.util.Daos;
import org.nutz.integration.quartz.NutQuartzCronJobFactory;
import org.nutz.ioc.Ioc;
import org.nutz.mvc.NutConfig;
import org.nutz.mvc.Setup;
public class MainSetup implements Setup {
public void init(NutConfig conf) {
Ioc ioc = conf.getIoc();
Dao dao = ioc.get(Dao.class);
Daos.createTablesInPackage(dao, "edu.taru", false);
// 获取NutQuartzCronJobFactory从而触发计划任务的初始化与启动
ioc.get(NutQuartzCronJobFactory.class);
}
public void destroy(NutConfig conf) {
}
}
jar包用的这两个:
quartz-2.2.2.jar
quartz-jobs-2.2.2.jar