spring定时器设定时间的问题

问题描述

我要每个星期的周六晚上23:59分调用一个action。以前没用过,在网上看那个时间规则看半天也不懂。自己写出来一个,一启动就报错。谁来帮我解决一下啊<!-- 每周六晚上23:55调用一次mysql存储过程,更新统计记录 --><bean id="weekLsPlayerTaskAction" class="com.peuo.wl.task.WeekLsPlayerTaskAction"/> <bean id="weekLsPlayerTaskActionTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject"> <ref bean="weekLsPlayerTaskAction"/> </property> <property name="targetMethod"> <value>doRun</value> </property></bean><bean id="weekLsPlayerActionTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail"> <ref bean="weekLsPlayerTaskActionTask"/> </property> <property name="cronExpression"> <!-- 每周六晚上23:55执行 --> <value>0 55 23 * * 6</value> </property></bean> <bean autowire="no"class="org.springframework.scheduling.quartz.SchedulerFactoryBean"><property name="triggers"><list><ref local="dayReportTaskActionTrigger" /><ref local="weekLsPlayerActionTrigger"/></list></property></bean> 问题补充:这是启动服务时报的错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean' defined in file [D:Program FilesTomcat 5.0webappssgsiWEB-INFclassesspringspring.task.cfg.xml]: Invocation of init method failed; nested exception is org.quartz.SchedulerException: Registration of jobs and triggers failed: Support for specifying both a day-of-week AND a day-of-month parameter is not implemented. [See nested exception: java.lang.UnsupportedOperationException: Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.]Caused by: org.quartz.SchedulerException: Registration of jobs and triggers failed: Support for specifying both a day-of-week AND a day-of-month parameter is not implemented. [See nested exception: java.lang.UnsupportedOperationException: Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.]at org.springframework.scheduling.quartz.SchedulerFactoryBean.registerJobsAndTriggers(SchedulerFactoryBean.java:789)at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:593)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4343)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:701)at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432)at org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)at org.apache.catalina.core.StandardService.start(StandardService.java:480)at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)at org.apache.catalina.startup.Catalina.start(Catalina.java:556)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:601)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)* Nested Exception (Underlying Cause) ---------------java.lang.UnsupportedOperationException: Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.at org.quartz.CronExpression.getTimeAfter(CronExpression.java:1234)at org.quartz.CronTrigger.getTimeAfter(CronTrigger.java:857)at org.quartz.CronTrigger.getFireTimeAfter(CronTrigger.java:587)at org.quartz.CronTrigger.computeFirstFireTime(CronTrigger.java:836)at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:646)at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:249)at org.springframework.scheduling.quartz.SchedulerFactoryBean.addTriggerToScheduler(SchedulerFactoryBean.java:840)at org.springframework.scheduling.quartz.SchedulerFactoryBean.registerJobsAndTriggers(SchedulerFactoryBean.java:770)at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:593)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4343)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:701)at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432)at org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)at org.apache.catalina.core.StandardService.start(StandardService.java:480)at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)at org.apache.catalina.startup.Catalina.start(Catalina.java:556)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:601)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)

解决方案

这么写0 55 23 ? * 6
解决方案二:
CRON表达式,秒 分 时 日 月 年你的要求 :周六的23点55分应该是这样:0 55 23 * * ? SAT
解决方案三:
看看错误日志。或者把错误贴上来看下。

时间: 2024-11-02 23:17:57

spring定时器设定时间的问题的相关文章

获取焦点时,利用js定时器设定时间执行动作_javascript技巧

进入正题,先说说定时器. 在javascritp中,有两个关于定时器的专用函数,分别为: 1.倒计定时器:timename=setTimeout("function();",delaytime); 2.循环定时器:timename=setInterval("function();",delaytime); 第一个参数"function()"是定时器触发时要执行的动作,可以是一个函数,也可以是几个函数,函数间用":"隔开即可.比

求spring 定时器 每天上午8点到晚上12点每10分钟运行一次定时规则

问题描述 求spring 定时器 每天上午8点到晚上12点每10分钟运行一次定时规则<property name="cronExpression" value="0 0/10 8-23 * * ?" />我是这样写的,无效ing求高手指正....谢谢 解决方案 贴下其他配置看看呢,单看<property name="cronExpression" value="0 0/10 8-23 * * ?" />

timer-spring quartz定时器任务时间超过定时器时间间隔,任务中断

问题描述 spring quartz定时器任务时间超过定时器时间间隔,任务中断 spring quartz定时器任务时间超过定时器时间间隔,任务中断. 大体意思就是,比如定时器是每隔十分钟进行一次,然后他执行的任务后来在10分钟之内执行不完,然后当下次定时器启动扫描的时候,第一次的任务还没有执行完,这个时候,这些任务就会被干掉,然后重新执行任务,对于这种问题,大婶们该怎么处理? 解决方案 如果这个任务方法时间过长那么就 起一个 线程处理处理

spring定时器怎么设置

问题描述 spring定时器怎么设置 spring定时器怎么设置为每半个小时触发一次,急急急,求大神告知 解决方案 接上一篇 : 0/5 * * * * ? ? ------------设置定义定时器(注意) 关键是设置 cronExpression属性 : cronExpression表达式有至少6个(也可能是7个)由空格分隔的时间元素.从左至右,这些元素的定义如下:? 1.秒(0–59)? 2.分钟(0–59)? 3.小时(0–23)?......答案就在这里:设置Spring定时器 解决方

JAVA中 Spring定时器的两种实现方式_java

目前有两种流行Spring定时器配置:Java的Timer类和OpenSymphony的Quartz. 1.Java Timer定时 首先继承java.util.TimerTask类实现run方法 import java.util.TimerTask; public class EmailReportTask extends TimerTask{ @Override public void run() { ... } } 在Spring定义 ... 配置Spring定时器 <bean id=&quo

关于spring定时器求帮忙

问题描述 写了个spring定时器,服务启动定时器也启动,但是每次去调用ApplicationContextac=newClassPathXmlApplicationContext("conf/spring/*.xml");去获取bean的的时候又会启动多一次定时器!!有没有什么办法解决? 解决方案 解决方案二:每次newClassPathXmlApplicationContext("conf/spring/*.xml");时再把new出来对象的定时器取消可以吗解决

spring定时器,怎么注入dao层?

问题描述 spring定时器,怎么注入dao层? 用的spring3.0 注解配置的定时器,基本功能(定时访问)能实现,现在想定时访问数据库,该怎么注入dao层呢?? 解决方案 百度半天,实在找不到相关的内容,才来求教... 解决方案二: 定时访问和定时访问数据库这两个有什么区别吗?没看懂 解决方案三: 自己顶...自己顶...自己顶...自己顶 解决方案四: 再定再定再定再定再定再定再定再定再定再定再定再定再定再定再定再定再定再定再定 解决方案五: 求大大求告知................

spring 定时器配置的问题

问题描述 spring 定时器配置的问题 错误码: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class 同样的配置在spring 3.1.0没问题,在spring 4.0.6就报告这个错误 是找不到这个类,求解 解决方案 在Spring4.0之后,石英调度(quartz)是集成在它的包里的;而在Spring3.0还需要自己导入包的. 你可以打开看看.两者是不是冲突了. 解决方案二:

时间段配置-quartz定时器框架时间配置

问题描述 quartz定时器框架时间配置 我想配置一个任务,触发时间是2014-02-25的每天13:00:00到2014-08-12的每天14:30:00,但中间的法定节日,如五一等(假设五一放假三天)节日不触发,这个如何配置