有没有什么东西可以在java中启动cron?
我编写了一些java来执行非常非常简单的操作。它需要每三个小时发生一次,并且与任何用户操作无关,它只是每三个小时循环一次。
因此,我在故障排除方面遇到了麻烦。手术没有进行。假设java完好无损,是否有什么东西应该“启动”cron?或者我应该期望它会在服务器重新启动后继续运行?
<bean id="queueJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.campbiche.pb.service.scheduler.BaseQuartzScheduler" />
<property name="jobDataAsMap">
<map>
<entry key="processorName" value="scheduleListingActions" />
<entry key="methodName" value="revolveQueue" />
</map>
</property>
</bean>
<bean id="queueCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="queueJob" />
<!-- run every 1 miunute -->
<property name="cronExpression" value="*/1 * * * * ?" />
</bean>
在 SpringSource 工作。 Cron 设置为一分钟进行测试。 "" 也已添加到 SchedulerFactoryBean bean 中,但为了简洁起见,我没有在此处包含代码。
I have some java written to do a very very simple operation. It needs to happen once every three hours and is not connected to any user action, it's just something that revolves every three hours.
For this reason, I'm having trouble troubleshooting. The operation isn't happening. Assuming the java is intact, is there something that is supposed to "start" the cron? Or should I expect it to just be going once the server is restarted?
<bean id="queueJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.campbiche.pb.service.scheduler.BaseQuartzScheduler" />
<property name="jobDataAsMap">
<map>
<entry key="processorName" value="scheduleListingActions" />
<entry key="methodName" value="revolveQueue" />
</map>
</property>
</bean>
<bean id="queueCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="queueJob" />
<!-- run every 1 miunute -->
<property name="cronExpression" value="*/1 * * * * ?" />
</bean>
Working in SpringSource. The Cron is set to one minute for testing. "" has already been added to a schedulerfactorybean bean as well but I did not include the code here for brevity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当
CronTriggerBean
实例化时会触发它。我还记得一件事,并在查看 docs(3.x),您需要将
queueCronTrigger
添加到SchedulerFactoryBean
。It will be triggered when
CronTriggerBean
is instantiated.One more thing I recall, and confirmed after looking in the docs(3.x), that you need to add your
queueCronTrigger
toSchedulerFactoryBean
.