private static final String APPLICATION_CONTEXT_KEY = "applicationContext";
public final ApplicationContext getApplicationContext(
JobExecutionContext context) throws JobExecutionException {
ApplicationContext applicationContext = null;
try {
applicationContext = (ApplicationContext) context.getScheduler()
.getContext().get(APPLICATION_CONTEXT_KEY);
} catch (SchedulerException e) {
throw new JobExecutionException(e);
}
return applicationContext;
}
<bean id="scheduler" name="springQuartz" lazy-init="false"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="quartzProperties">
<props>
<prop key="org.quartz.scheduler.instanceName">
SpringScheduler
</prop>
<prop key="org.quartz.scheduler.instanceId">AUTO</prop>
<prop key="org.quartz.jobStore.class">
org.quartz.impl.jdbcjobstore.JobStoreTX
</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">
org.quartz.impl.jdbcjobstore.StdJDBCDelegate
</prop>
<prop key="org.quartz.jobStore.tablePrefix">
meta_task_
</prop>
</props>
</property>
<property name="applicationContextSchedulerContextKey">
<value>applicationContext</value>
</property>
因篇幅问题不能全部显示,请点此查看更多更全内容