Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 弹簧自动接线不适用于石英_Java_Spring_Quartz Scheduler - Fatal编程技术网

Java 弹簧自动接线不适用于石英

Java 弹簧自动接线不适用于石英,java,spring,quartz-scheduler,Java,Spring,Quartz Scheduler,我有一个web应用程序,我使用spring应用程序上下文注入我的bean,在我的应用程序中用@Autowired注释。我有一个服务,它有一个生成报告的方法,该服务如下: public ReportingService extends CommonService { //this method is called from a controller to generate a report right now //after filling the parameters of the report

我有一个web应用程序,我使用spring应用程序上下文注入我的bean,在我的应用程序中用@Autowired注释。我有一个服务,它有一个生成报告的方法,该服务如下:

public ReportingService extends CommonService {
//this method is called from a controller to generate a report right now
//after filling the parameters of the report i.e. businessday
public generateReport(Request request) {.....}  
public generateScheduledReport() {
//read configured parameters from database and fill request
Request rr = ...;
generateReport(request);
}
public class ScheduledReportJob extends QuartzJobBean {
@Autowired
@Qualifier("reportScheduler")
CommonService reportScheduler;
//getters and setters  
@Override
protected void executeInternal(JobExecutionContext arg0)
        throws JobExecutionException {
    reportScheduler.generateScheduledReport();
对于计划报告,我定义了一个扩展QuartzJobBea`的作业,并使用ReportingService的一个字段调用其generateScheduledReport,如下所示:

public ReportingService extends CommonService {
//this method is called from a controller to generate a report right now
//after filling the parameters of the report i.e. businessday
public generateReport(Request request) {.....}  
public generateScheduledReport() {
//read configured parameters from database and fill request
Request rr = ...;
generateReport(request);
}
public class ScheduledReportJob extends QuartzJobBean {
@Autowired
@Qualifier("reportScheduler")
CommonService reportScheduler;
//getters and setters  
@Override
protected void executeInternal(JobExecutionContext arg0)
        throws JobExecutionException {
    reportScheduler.generateScheduledReport();
在我的applicationContext中,我将quartz和spring bean设置如下:

 <bean id"reportScheduler" class="com.monim.ReportingService"/>
 <bean name="schedulingjob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
     <property name="jobClass"
        value="com.monim.ScheduledReportJob " />
     <property name="name" value="name" />
     <property name="group" value="group"/>
     <property name="durability" value="true" />
 </bean>
 <bean id="trigger"
    class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
     <property name="name" value="name" />
     <property name="group" value="group" />
     <property name="jobDetail" ref="schedulingjob" />  
     <property name="cronExpression" value="0/5 * * * * ?" />
    <!-- MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY - SEE MISFIRE INSTRUCTIONS 
    <property name="misfireInstruction" value="1" />  
  <bean id="Scheduler"
    class="org.springframework.scheduling.quartz.SchedulerFactoryBean"
    p:waitForJobsToCompleteOnShutdown="false" lazy-init="true">
     <property name="dataSource" ref="dataSource" />
     <property name="transactionManager" ref="transactionManager" />  
    <property name="overwriteExistingJobs" value="false" />
    <property name="quartzProperties">  
 <map>  
 <!-- scheduler configuration -->
 <entry key="org.quartz.scheduler.instanceName" value="scheduler" />
 <entry key="org.quartz.scheduler.skipUpdateCheck" value="true" />
 <entry key="org.quartz.jobStore.misfireThreshold" value="60000" />
 <!-- JobStore configuration -->
 <entry key="org.quartz.jobStore.class" value="org.quartz.impl.jdbcjobstore.JobStoreCMT" />
 <entry key="org.quartz.jobStore.dataSource" value="dataSource" />
 <entry key="org.quartz.jobStore.nonManagedTXDataSource" value="quartzDataSource" />
 <entry key="org.quartz.jobStore.driverDelegateClass" value="org.quartz.impl.jdbcjobstore.oracle.OracleDelegate"/>
<entry key="org.quartz.jobStore.tablePrefix" value="QRTZ_" />
<entry key="org.quartz.jobStore.useProperties" value="true" />
<entry key="org.quartz.jobStore.selectWithLockSQL"
value="SELECT * FROM {0}LOCKS WHERE SCHED_NAME = {1} AND LOCK_NAME = ? FOR UPDATE" />
<entry key="org.quartz.jobStore.isClustered" value="false" />
<!-- ThreadPool configuration -->
<entry key="org.quartz.threadPool.class" value="org.quartz.simpl.SimpleThreadPool" />
<entry key="org.quartz.threadPool.threadCount" value="3" />
</map>  
</property>  
<property name="applicationContextSchedulerContextKey">
    <value>applicationContext</value>
</property>
<property name="jobDetails">
<list>
<ref bean="schedulingjob" />
</list>
</property>
<property name="triggers">
<list>
<ref bean="trigger" />
</list>
</property>
</bean>

应用程序上下文

我的ReportingService包含对其他bean的引用,这些bean也通过应用程序上下文注入。我的问题是调度程序正在工作并已成功启动,但用于调度作业的所有注入bean都已初始化为null,请提供帮助在搜索了许多线程和博客后,我通过执行以下操作使我的应用程序工作: 在方法
executeInternal
的第一行中,我放了这一行:
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this)
这是我从一个答案中发现的
然后我启动了应用程序“stillbeansnotinjected”,但这使得quartz将其触发器保存到数据库中,稍后将使用该数据库。之后,我将以下属性添加到我的作业bean中:

  <property name="jobDataAsMap">
    <map>
      <entry key="schedulerTask" value-ref="reportWithTWService" />
     </map>
  </property>


一切都很顺利。但是,当在石英表为空的情况下添加这些属性时,它不起作用,我仍然希望有人能向我解释发生了什么事

在搜索了许多线程和博客后,我通过执行以下操作使我的应用程序工作: 在方法
executeInternal
的第一行中,我放了这一行:
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this)
这是我从一个答案中发现的
然后我启动了应用程序“stillbeansnotinjected”,但这使得quartz将其触发器保存到数据库中,稍后将使用该数据库。之后,我将以下属性添加到我的作业bean中:

  <property name="jobDataAsMap">
    <map>
      <entry key="schedulerTask" value-ref="reportWithTWService" />
     </map>
  </property>


一切都很顺利。但在石英表为空的情况下添加这些属性不起作用,我仍然希望有人能向我解释发生了什么

我的解决方案就是基于这个解决方案的。它也正常工作。我的解决方案就是基于这个解决方案的。它也正常工作。