Spring 2.5 + quartz java.lang.NoClassDefFoundError:org / quartz / JobDetail

时间:2012-01-30 09:41:31

标签: java spring maven quartz-scheduler

石英库存在问题。我在春季2.5使用它:

<bean id="reminderBean" class="com.mail.timexis.ReminderBean">
        <property name="mailSender">
            <ref local="timexisMailSender" />
        </property>
    </bean>

    <bean id="jobDetail"
        class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject" ref="reminderBean" />
        <property name="targetMethod" value="execute" />
    </bean>

    <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail" ref="jobDetail" />
        <!-- run every morning at 6 AM -->
        <property name="cronExpression" value="* * * * * ?" />
    </bean>

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

的Maven:

<dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
            <version>1.8.4</version>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2</version>
        </dependency>

当我运行tomcat时,它无法实例化“jobDetail”bean,因为它无法看到MethodInvokingJobDetailFactoryBean类( Caused by: java.lang.NoClassDefFoundError: org/quartz/JobDetail)使用的JobDetail类

Maven下载了jar,我可以在MavenDependencies下看到它,我可以找到JobDetail类。

我认为这与弹簧2.5和石英的兼容性有关。有什么想法吗?

1 个答案:

答案 0 :(得分:5)

您是否将依赖项添加到spring-context-support

它包含根据堆栈跟踪似乎缺少的org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean