简体   繁体   English

Java Web应用程序的入口点

[英]Entry point for java web application

I need to know where i can start a cron in my java web app. 我需要知道在Java Web应用程序中可以在哪里启动cron。 I need this cron to run daily and be rescheduled if the server restarts. 我需要该cron每天运行,并在服务器重新启动时重新计划。 Do java web application have hook where i can do this? Java Web应用程序在我可以执行此操作的地方有钩子吗?

----edits---- ---- ----编辑

Im using quartz to schedule a task which will pull down and parse a csv file and store it in a database. 我使用石英来调度任务,该任务将下拉并解析csv文件并将其存储在数据库中。 I need to know where i should schedule it to run the first time 我需要知道我应该在哪里安排第一次运行

You might want to use a ServletContextListener . 您可能要使用ServletContextListener It supports two methods that run when an web app is started and ended. 它支持在启动和结束Web应用程序时运行的两种方法。 This article goes over setting one up. 本文介绍了一个设置。 You can start the Quartz scheduler in the Initialize method and shut it down in the Destroy method. 您可以在Initialize方法中启动Quartz调度程序,并在Destroy方法中将其关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM