WEBAPP开发教程Quartz实例简介
凌雪 2018-11-08 来源 :网络 阅读 1205 评论 0

摘要:本文将带你了解WEBAPP开发教程Quartz实例简介,希望本文对大家学WEBAPP有所帮助。

本文将带你了解WEBAPP开发教程Quartz实例简介,希望本文对大家学WEBAPP有所帮助。


[size=9]项目简称webapp1.将Quartz的quartz-all-1.5.2.jar文件放入webapp的WEB-INF\lib下2.在webapp的web.xml中加入:<servlet>    <servlet-name>QuartzInitializer</servlet-name>  <servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-class>    <load-on-startup>1</load-on-startup></servlet>3.然后新建一个quartz.properties,放在webapp的classpath下面,即src下:##   Configure Main Scheduler Properties #org.quartz.scheduler.instanceName =   TestSchedulerorg.quartz.scheduler.instanceId = one## Configure ThreadPool   #org.quartz.threadPool.class =   org.quartz.simpl.SimpleThreadPoolorg.quartz.threadPool.threadCount =  5org.quartz.threadPool.threadPriority = 4##   Configure JobStore #org.quartz.jobStore.misfireThreshold =   5000org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore#   ===========================================================================#   Configure SchedulerPlugins    ===============================================#   ===========================================================================org.quartz.plugin.triggHistory.class   =   org.quartz.plugins.history.LoggingTriggerHistoryPluginorg.quartz.plugin.triggHistory.triggerFiredMessage   = Trigger {1}.{0} fired job {6}.{5} at: {4, date, HH:mm:ss   MM/dd/yyyy}org.quartz.plugin.triggHistory.triggerCompleteMessage = Trigger   {1}.{0} completed firing job {6}.{5} at {4, date, HH:mm:ss MM/dd/yyyy} with   resulting trigger instruction code: {9}org.quartz.plugin.jobInitializer.class   =   org.quartz.plugins.xml.JobInitializationPlugin#定义quartz_reminder.xml(见下一步)的路径org.quartz.plugin.jobInitializer.fileName   = /quartz_reminder.xmlorg.quartz.plugin.jobInitializer.overWriteExistingJobs   = falseorg.quartz.plugin.jobInitializer.failOnFileNotFound =   trueorg.quartz.plugin.shutdownhook.class =   org.quartz.plugins.management.ShutdownHookPluginorg.quartz.plugin.shutdownhook.cleanShutdown   = true4.新建一个quartz_reminder.xml,其中定义job和trigger的信息:<?xml   version="1.0" encoding="UTF-8"?><quartz   xmlns="//www.opensymphony.com/quartz/JobSchedulingData"          xmlns:xsi="//www.w3.org/2001/XMLSchema-instance"          overwrite-existing-jobs="true">    <job>        <job-detail>            <!-- job 的名字 -->              <name>test-job</name>              <group>DEFAULT</group>            <description>The job   description</description>              <!-- job类的路径加类名 -->              <job-class>com.joysen.rule.scheduler.MyJob</job-class>            <!-- job-data-map   allows-transient-data="false">                <entry>                      <key>burger-type</key>                      <value>hotdog</value>                </entry>                <entry>                      <key>dressing-list</key>                      <value>ketchup,mayo</value>                </entry>            </job-data-map -->        </job-detail>        <trigger>            <cron>                <!-- trigger 的名字   -->                  <name>test-trigger</name>                  <group>DEFAULT</group>                <!-- trigger对应的job的相关信息   -->                  <job-name>test-job</job-name>                  <job-group>DEFAULT</job-group>                <!-- 每5秒执行一次 -->                <cron-expression>0/5 *   * * * ?</cron-expression>              </cron>          </trigger>      </job></quartz>注:cron-expression表示执行job的时间5.然后在com.joysen.rule.scheduler下面新建MyJob.java文件MyJob必须实现Quartz的Job接口public   class MyJob implements Job {  public   void execute(JobExecutionContext context) throws JobExecutionException {  //在控制台输出如下信息。    System.out.println("Quartz   Test");  }}[/size]    

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之WebApp频道!

本文由 @凌雪 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved