我需要在检索使用Quartz从数据库中的数据有所帮助。 我从主类config.xml中读取休眠特性和使用我试图检索我的工作类(石英Process.java)这是越来越空指针异常数据的属性。
请帮我解决这个问题。 感谢和前进
这是我的主类:
@Component("TestProgram")
public class TestProgram
{
static ClassPathXmlApplicationContext applicationContext=null;
public void testMethod() throws SchedulerException
{
JobDetail job = new JobDetail();
job.setName("Retriving The Master Details");
job.setJobClass(QuartzProcess.class);
SimpleTrigger trigger = new SimpleTrigger();
trigger.setName("Trigger For Retriving The Master Details");
trigger.setStartTime(new Date(System.currentTimeMillis() + 1000));
trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
trigger.setRepeatInterval(5000);
Scheduler scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
scheduler.scheduleJob(job, trigger);
}
public static void main(String[] args) throws Exception
{
String conf[] = {"Config.xml"};
applicationContext= new ClassPathXmlApplicationContext(conf);
TestProgram unittest=applicationContext.getBean(TestProgram.class);
unittest.testMethod();
}
}
石英Process.java
@Component("QuartzProcess")
public class QuartzProcess implements Job
{
@Autowired
private MasterService MasterService;
@Override
public void execute(JobExecutionContext jec) throws JobExecutionException
{
try
{
List<MasterVO> MasterVO=MasterService.findAll();
System.out.println("MasterVO..."+MasterVO);
for(int index=0;index<MasterVO.size();index++)
System.out.println(MasterVO.get(index));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}