public class TestJob implements StatefulJob { @Override public void execute(JobExecutionContext jectx) throws JobExecutionException { System.out.println("do some thing"); } public static void main(String[] args) throws SchedulerException, ParseException { SchedulerFactory sf = new StdSchedulerFactory(); // 1 获得调度器 Scheduler scheduler = sf.getScheduler(); JobDetail job = new JobDetail("hello_world_job", TestJob.class); // 2创建任务 // s m h d M w Trigger triger = new CronTrigger("xtrigger", null, "* * * * * ?"); // 3创建定时触发器 // triger =triger = TriggerUtils.makeSecondlyTrigger(); triger.setName("x_trigger"); scheduler.scheduleJob(job, triger); // 4 设定任务 scheduler.start(); // 5 启动 } }