我需要帮助来使用 Quartz 从数据库中检索数据。我正在从主类中的 config.xml 中读取休眠属性,并使用这些属性尝试从我的作业类 (Quartz 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();
}
}
石英工艺.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();
}
}
}