日期:2014-05-19 浏览次数:20749 次
SchedulerFactoryBean schedulerFactory=new SchedulerFactoryBean(); MethodInvokingJobDetailFactoryBean methodinvoking=new MethodInvokingJobDetailFactoryBean(); A aa=new A(); methodinvoking.setTargetObject(aa); methodinvoking.setTargetMethod("execute"); methodinvoking.setConcurrent(false); CronTriggerBean ctrigger=new CronTriggerBean(); //关键是这部不会,因为它的参数是要JobDetail,但是XML里面怎么可以直接把methodinvoking它放进去呢? ctrigger.setJobDetail(); ctrigger.setCronExpression("0/5 * * * * ?"); Trigger[] triggers={ctrigger}; schedulerFactory.setTriggers(triggers); schedulerFactory.start(); System.out.println(schedulerFactory.isRunning());