Java 在Spring中使用Quartz创建多个触发器及其各自的作业

Java 在Spring中使用Quartz创建多个触发器及其各自的作业,java,spring,quartz-scheduler,Java,Spring,Quartz Scheduler,我有两个不同的触发器和两个不同的工作。TimerOrd1和TimerOrd2是两个不同的Java类,它们同时处理,延迟相同,但它们是不同的类 仅供参考,TimeLord课程没有问题 我得到了一个例外: Stacktrace ERROR JobRunShell: Job DEFAULT.runScheduleJob1 threw an unhandled Exception: java.lang.NullPointerException at service.quartz.RunSche

我有两个不同的触发器和两个不同的工作。TimerOrd1和TimerOrd2是两个不同的Java类,它们同时处理,延迟相同,但它们是不同的类

仅供参考,TimeLord课程没有问题

我得到了一个例外:

Stacktrace

ERROR JobRunShell: Job DEFAULT.runScheduleJob1 threw an unhandled Exception: 
java.lang.NullPointerException
    at service.quartz.RunScheduleJob.executeInternal(RunScheduleJob.java:17)
    at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
15:56:17,736 [] ERROR JobRunShell: Job DEFAULT.runScheduleJob2 threw an unhandled Exception: 
java.lang.NullPointerException
    at service.quartz.RunScheduleJob.executeInternal(RunScheduleJob.java:17)
    at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
15:56:17,738 [] ERROR ErrorLogger: Job (DEFAULT.runScheduleJob1 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:210)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
    <bean name="runScheduleJob1" class="org.springframework.scheduling.quartz.JobDetailBean">
            <property name="jobClass" value="service.quartz.RunScheduleJob" />
            <property name="jobDataAsMap">
                <map>
                    <entry key="runScheduleTask1" value-ref="timeLord1" />
                </map>
            </property>
        </bean>

    <bean name="runScheduleJob2" class="org.springframework.scheduling.quartz.JobDetailBean">
            <property name="jobClass" value="service.quartz.RunScheduleJob" />
            <property name="jobDataAsMap">
                <map>
                    <entry key="runScheduleTask2" value-ref="timeLord2" />
                </map>
            </property>
        </bean>

<bean id="simpleTrigger1"
                class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        <property name="jobDetail" ref="runScheduleJob1" />
        <property name="repeatInterval" value="500" />
        <property name="startDelay" value="10" />
    </bean>


<bean id="simpleTrigger2"
                class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        <property name="jobDetail" ref="runScheduleJob2" />
        <property name="repeatInterval" value="500" />
        <property name="startDelay" value="10" />
    </bean>


<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="jobDetails">
            <list>
                <ref bean="runScheduleJob" />
            </list>
        </property>

        <property name="triggers">
            <list>
                <ref bean="simpleTrigger1" />
                <ref bean="simpleTrigger2" />
            </list>
        </property>
    </bean>
代码

ERROR JobRunShell: Job DEFAULT.runScheduleJob1 threw an unhandled Exception: 
java.lang.NullPointerException
    at service.quartz.RunScheduleJob.executeInternal(RunScheduleJob.java:17)
    at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
15:56:17,736 [] ERROR JobRunShell: Job DEFAULT.runScheduleJob2 threw an unhandled Exception: 
java.lang.NullPointerException
    at service.quartz.RunScheduleJob.executeInternal(RunScheduleJob.java:17)
    at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
15:56:17,738 [] ERROR ErrorLogger: Job (DEFAULT.runScheduleJob1 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:210)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
    <bean name="runScheduleJob1" class="org.springframework.scheduling.quartz.JobDetailBean">
            <property name="jobClass" value="service.quartz.RunScheduleJob" />
            <property name="jobDataAsMap">
                <map>
                    <entry key="runScheduleTask1" value-ref="timeLord1" />
                </map>
            </property>
        </bean>

    <bean name="runScheduleJob2" class="org.springframework.scheduling.quartz.JobDetailBean">
            <property name="jobClass" value="service.quartz.RunScheduleJob" />
            <property name="jobDataAsMap">
                <map>
                    <entry key="runScheduleTask2" value-ref="timeLord2" />
                </map>
            </property>
        </bean>

<bean id="simpleTrigger1"
                class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        <property name="jobDetail" ref="runScheduleJob1" />
        <property name="repeatInterval" value="500" />
        <property name="startDelay" value="10" />
    </bean>


<bean id="simpleTrigger2"
                class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        <property name="jobDetail" ref="runScheduleJob2" />
        <property name="repeatInterval" value="500" />
        <property name="startDelay" value="10" />
    </bean>


<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="jobDetails">
            <list>
                <ref bean="runScheduleJob" />
            </list>
        </property>

        <property name="triggers">
            <list>
                <ref bean="simpleTrigger1" />
                <ref bean="simpleTrigger2" />
            </list>
        </property>
    </bean>

尝试取出此部件:

 <property name="jobDetails">
            <list>
                <ref bean="runScheduleJob" />
            </list>
        </property>


您可以在触发器中定义jobDetails。

哪里定义了
runScheduleJob
?我得到了这个异常:
错误设置属性值;嵌套异常为org.springframework.beans.NotWritablePropertyException:bean类[org.springframework.scheduling.quartz.SimpleTriggerBean]的无效属性“jobDetails”:bean属性“jobDetails”不可写或具有无效的setter方法。你是说“工作细节”吗?