论坛首页 Java企业应用论坛

关于Spirng Quartz定时触发器+源码示例!

浏览 13077 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-04-23  
0 0,15,30,45 * 1-10 * ?                每月前10天每隔15分钟
lz,这个好像不对吧
0 请登录后投票
   发表时间:2012-04-23  
resp 写道
dailindl 写道
shmily2038 写道
slertname 写道
spring3.1已经不用quartz了,有spring自己实现的定时任务。
根本不用这么麻烦。

那spring3.1用什么来实现? 愿听其详,呵呵,谢谢。

同问,谢谢


请教下,不用quartz如果用Spring自己实现定时任务?


<task:scheduled-tasks>
<task:scheduled ref="bean" method="doSomeThing" cron="*/5 * * * * ?" />
</task:scheduled-tasks>


ok。是不是方便很多呢。一楼的标注式应该也可以。
0 请登录后投票
   发表时间:2012-04-23  
有动态传入触发时间的解决办法吗
0 请登录后投票
   发表时间:2012-04-24  
quartz  官网上就有例子的
0 请登录后投票
   发表时间:2012-04-24  
quartz+Spring,有个有趣的问题,当你不小心import quartz 配置文件多次的话,你所已定义的时间就会跑多次。。
0 请登录后投票
   发表时间:2012-04-25   最后修改:2012-04-25

还是用org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean好,这样类不用继承

 

<!-- Task -->
	<bean id="receiveTask" class="com.xxxx.work.receive.schedule.ReceiveCusGraphicTask">
		<property name="receiveService" ref="receiveService" />
	</bean>

	<!-- Invoke Job -->
	<bean id="receiveJob"
		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject" ref="receiveTask" />
		<property name="targetMethod" value="startReceive" />
	</bean>

	<!-- Trigger bind Job -->
	<bean id="receiveTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="receiveJob" />
		<property name="cronExpression" value="0 0/1 16 * * ?" />
	</bean>

	<!-- Manager -->
	<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="configLocation" value="config/quartz.properties" />
		<property name="triggers">
			<list>
				<ref bean="receiveTrigger" />
			</list>
		</property>
	</bean>
 
0 请登录后投票
   发表时间:2012-04-26  
其实有的时候自己更关注,spring 的定时任务可以在页面中进行调节.
0 请登录后投票
   发表时间:2013-01-07  
严重: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/timerDemo]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextException
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
at java.lang.Class.getDeclaredFields(Class.java:1743)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:87)
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:90)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:382)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:858)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:346)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
... 25 more
2013-1-7 9:35:59 org.apache.catalina.startup.HostConfig deployDirectory
严重: Error deploying web application directory C:\Program Files\apache\apache-tomcat-7.0.29-test\webapps\timerDemo
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/timerDemo]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
2013-1-7 9:35:59 org.apache.coyote.AbstractProtocol start
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics