我的调度程序正在触发,但我无法连接到数据库。当我尝试使用测试用例查询数据库时,它起作用了,所以我尝试使用 Quartz 来实现它,但它给出了NullPointerException
.
public class JobScheduler extends QuartzJobBean {
@Autowired
ISourceService sourcedao;
@Override
protected void executeInternal(JobExecutionContext arg0)
throws JobExecutionException {
Client client = new Client();
client.setClientKey(300);
Source sourceobj = sourcedao.getSourceByClient(client);
String sourcetype = sourceobj.getSourceType();
System.out.println(sourcetype);
}
}
我的应用程序 context.xml
<bean id="jobScheduler" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.dca.scheduling.JobScheduler" />
<property name="jobDataAsMap">
<map>
<entry key="timeout" value="5" />
</map>
</property>
</bean>
<bean id="cronTriggerjobScheduler" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="jobScheduler" />
<property name="cronExpression" value="0/15 0 * * * ?" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="jobDetails">
<list>
<ref bean="jobScheduler" />
</list>
</property>
<property name="triggers">
<list>
<ref bean="cronTriggerjobScheduler" />
</list>
</property>
</bean>
<bean id="jobClass"
class="com.dca.scheduling.JobScheduler">
</bean>
我检查了很多例子,但没有得到任何想法。