最近做一个 Spring4.1.0 集成 quartz1.8.2 定时器功能,一直报 class not found : org.springframework.scheduling.quartz.JobDetailBean ;

困扰许久,后来仔细检查发现问题为 :spring-context-support-3.1.0.RELEASE.jar 包没有; 后导入,代码成功编译;贴出代码,以免再犯错!

 

1.application 配置如下:

 

<bean name="exampleJob" class="org.springframework.scheduling.quartz.JobDetailBean">  
        <property name="jobClass" value="com.noahwm.bigscreen.test.MyJob" />  
        <property name="jobDataAsMap">  
            <map>  
                <entry key="timeout" value="5" />  
            </map>  
        </property>  
    </bean>  
    <bean />  -->
            </list>  
        </property>  
    </bean> 

 

2.测试class如下:

 

package com.noahwm.bigscreen.test;
import java.util.Date;

import org.quartz.JobExecutionContext;  
import org.quartz.JobExecutionException;  
import org.springframework.scheduling.quartz.QuartzJobBean;
public class MyJob extends QuartzJobBean {  
    
     @Override
     protected void executeInternal(JobExecutionContext arg0)
             throws JobExecutionException {
         // TODO Auto-generated method stub
         System.out.println("调用任务--"+new Date());
     }
}    

 

3.jar包如下

Spring4.1.0 整合quartz1.8.2 时 : class not found : org.springframework.scheduling.quartz.JobDetailBeanSpring4.1.0 整合quartz1.8.2 时 : class not found : org.springframework.scheduling.quartz.JobDetailBean

 

4.控制台打印如下 :

 

Spring4.1.0 整合quartz1.8.2 时 : class not found : org.springframework.scheduling.quartz.JobDetailBean

 

CronTriggershi时间配置范例:

 

0 0 12 * * ?           每天12点触发
0 15 10 ? * *          每天10点15分触发
0 15 10 * * ?          每天10点15分触发 
0 15 10 * * ? *        每天10点15分触发 
0 15 10 * * ? 2005     2005年每天10点15分触发
0 * 14 * * ?           每天下午的 2点到2点59分每分触发
0 0/5 14 * * ?         每天下午的 2点到2点59分(整点开始,每隔5分触发) 
0 0/5 14,18 * * ?        每天下午的 18点到18点59分(整点开始,每隔5分触发)

 

 

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2021-07-17
  • 2022-12-23
  • 2021-06-30
  • 2022-12-23
猜你喜欢
  • 2021-04-19
  • 2021-06-26
  • 2022-01-09
  • 2021-09-14
  • 2022-12-23
相关资源
相似解决方案