spring对定时任务调度集成的总结

1.TimerTask
>>配置文件default-lazy-init="false"如果为true则不会启动Timer

>>INFO [org.springframework.scheduling.timer.TimerFactoryBean] - Initializing Timer
表示启动了定时.

>>但是用AbstractDependencyInjectionSpringContextTests这个类来加载spring的配置文件后虽然启动了定时任务,但是马上执行以下步骤:
Closing application context
Destroying singletons in...
Cancelling Timer
所以定时任务不能执行.
>>如果使用new ClassPathXmlApplicationContext(String[])来加载配置文件,则在Initializing Timer后就程序就退出了,真是怪事.

>>用org.springframework.web.context.ContextLoaderListener 在web应用环境下加载配置文件可以正确执行定时任务.
spring bean配置如下:

<bean id="scheduledTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="delay" value="1000" />
<property name="period" value="50000" />
<property name="timerTask" ref="scoringService" />
</bean>
<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref bean="scheduledTask" />
</list>
</property>
<property name="daemon" value="true"/>
</bean>

2.quartz
>>使用autowire by name的禁忌:不要有叫dataSource的bean存在.
见http://eyejava.iteye.com/blog/58281

>>cronExpression和unix cronTab文件的区别
cronTab没有秒 和 年这两个栏位,cronTab 的星期天用0表示,cronExpression用7表示

>>cronExpression:
[quote]
字段 允许值 允许的特殊字符
秒 0-59 , - * /
分 0-59 , - * /
小时 0-23 , - * /
日期 1-31 , - * ? / L W C
月份 1-12 或者 JAN-DEC , - * /
星期 1-7 或者 SUN-SAT , - * ? / L C #
年(可选) 留空, 1970-2099 , - * /
The '*' character is used to specify all values. For example, "*" in the minute field means "every minute".
“*”字符被用来指定所有的值。如:”*“在分钟的字段域里表示“每分钟”。
The '?' character is allowed for the day-of-month and day-of-week fields. It is used to specify 'no specific value'. This is useful when you need to specify something in one of the two fileds, but not the other. See the examples below for clarification.
“?”字符只在日期域和星期域中使用。它被用来指定“非明确的值”。当你需要通过在这两个域中的一个来指定一些东西的时候,它是有用的。看下面的例子你就会明白。
The '-' character is used to specify ranges For example "10-12" in the hour field means "the hours 10, 11 and 12".
“-”字符被用来指定一个范围。如:“10-12”在小时域意味着“10点、11点、12点”。
The ',' character is used to specify additional values. For example "MON,WED,FRI" in the day-of-week field means "the days Monday, Wednesday, and Friday".
“,”字符被用来指定另外的值。如:“MON,WED,FRI”在星期域里表示”星期一、星期三、星期五”.
The '/' character is used to specify increments. For example "0/15" in the seconds field means "the seconds 0, 15, 30, and 45". And "5/15" in the seconds field means "the seconds 5, 20, 35, and 50". Specifying '*' before the '/' is equivalent to specifying 0 is the value to start with. Essentially, for each field in the expression, there is a set of numbers that can be turned on or off. For seconds and minutes, the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to 31, and for months 1 to 12. The "/" character simply helps you turn on every "nth" value in the given set. Thus "7/6" in the month field only turns on month "7", it does NOT mean every 6th month, please note that subtlety.
The 'L' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "last", but it has different meaning in each of the two fields. For example, the value "L" in the day-of-month field means "the last day of the month" - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means "7" or "SAT". But if used in the day-of-week field after another value, it means "the last xxx day of the month" - for example "6L" means "the last friday of the month". When using the 'L' option, it is important not to specify lists, or ranges of values, as you'll get confusing results.
The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the day-of-month field, the meaning is: "the nearest weekday to the 15th of the month". So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can only be specified when the day-of-month is a single day, not a range or list of days.
The 'L' and 'W' characters can also be combined for the day-of-month expression to yield 'LW', which translates to "last weekday of the month".
The '#' character is allowed for the day-of-week field. This character is used to specify "the nth" XXX day of the month. For example, the value of "6#3" in the day-of-week field means the third Friday of the month (day 6 = Friday and "#3" = the 3rd one in the month). Other examples: "2#1" = the first Monday of the month and "4#5" = the fifth Wednesday of the month. Note that if you specify "#5" and there is not 5 of the given day-of-week in the month, then no firing will occur that month.
The 'C' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "calendar". This means values are calculated against the associated calendar, if any. If no calendar is associated, then it is equivalent to having an all-inclusive calendar. A value of "5C" in the day-of-month field means "the first day included by the calendar on or after the 5th". A value of "1C" in the day-of-week field means "the first day included by the calendar on or after sunday".
[/quote]
Ubuntu下安装Hive3.1.2教程(附MySQL安装方法及安装包) 文章目录前言一、安装Hive1. 下载压缩包并解压2. 安装Hive3. 配置环境变量4. 修改配置文件二、MySQL安装与配置1. 安装MySQL2. 安装MySQL jdbc包3. 为Hive创建MySQL账号三、验证Hive安装及错误处理1. 启动Hadoop2. 启动hive3. 运行Hive实例总结 前言 Hive 的安装需要建立在 Hadoop 的之上(类似于Hbase),关于 Hadoop 的单机安装以及伪分布式安装可以参考作者的另两篇博客: Ubuntu下单机安装Hadoop详细教程(附 阅读详情

相关推荐

win11本地部署openclaw实操第5集-X11图形化界面搭建,让WSL2“看见”世界

本文介绍了在WSL2中实现图形界面(GUI)的方法。由于WSL2默认没有图形界面,需要使用X11服务器作为"翻译显示器",将Linux程序的图形指令渲染到Windows窗口中。推荐使用VcXsrv作为X11服务器,详细说明了其安装和配置步骤,包括选择"One large window"显示模式、禁用访问控制等关键设置。随后在Ubuntu中安装轻量级xfce4桌面环境,并通过设置DISPLAY环境变量将图形输出指向VcXsrv。最终通过startxfce4命令成功在Vc

weixin_44626085的博客 812

如何在spring中配置定时任务(job)

首先,如果你在web.xml文件中的配置是这样的:          contextConfigLocation                 /WEB-INF/classes/applicationContext-*.xml         那么需要在工程下创建一个以applicationContext- 为开头的xml文件eg:applicationContext-jobconfig

feifniao的专栏 4656

【AI生成】 LoRa无中心自组网实现方案

LoRa技术是一种低功耗广域网通信技术,它采用了扩频频率调制技术,能够实现远距离的传输。LoRa在物联网中具有重要的应用价值,可以支持大规模的设备连接并且具有较低的成本。同时,LoRa具有高度的抗干扰能力和适应性,能够在复杂的环境中实现稳定的通信。通过使用无中心自组网实现方案,可以进一步提高LoRa网络的灵活性和可靠性,实现设备之间的智能互联。LoRa无中心自组网实现方案将为物联网应用提供更加便捷和高效的通信解决方案。LoRa无中心自组网实现方案一、无中心自组网概念及优势。

qq_31310977的博客 2090

Spring Boot集成Quartz定时任务调度

Spring Boot集成Quartz定时任务调度大家好,我是微赚淘客返利系统3.0的小编,是个冬天不穿秋裤,天冷也要风度的程序猿!Quartz是一个开源的Java任务调度库,用于在后台运行定时任务。Spring Boot集成Quartz可以简化定时任务的配置和管理。以下是如何在Spring Boot中集成Quartz并实...

weixin_40480220的博客 104

华硕ROG幻16笔记本电脑模式切换管理工具完美替代华硕奥创中心管理工具

参考文档1这个工具可以完美替代华硕奥创中心工具,可以定制化不同模式下的CPU、GPU、风扇转速、电池计划等。是由华硕开发人员开发的一个纯绿色的系统管理工具。直接展示启动后的工具界面效果图:这个工具也可以一键式停止正在运行的华硕ASUS服务,减少不必要的资源消耗。

追梦&天空的博客 1万+

【实战解析】Ubuntu双网卡冲突:如何解决同一网段下网关无法访问及上网问题

本文深入解析Ubuntu服务器双网卡配置在同一网段时引发的路由冲突问题,导致网关无法ping通及无法上网。通过分析路由表与Metric值原理,提供使用route命令调整优先级及修改Netplan配置文件的实战解决方案,确保主次路由明确,一劳永逸解决网络冲突。

f9g0h的博客 284

Spring Cloud Alibaba 集成分布式定时任务调度功能

Spring Cloud Alibaba 发布了 Scheduling 任务调度[1]模块 [#3732][2]提供了一套开源、轻量级、高可用的定时任务解决方案,帮助您快速开发微服务体系下的分布式定时任务。

阿里巴巴云原生的博客 1603

ArcGIS实战:手把手教你用DEM和灾害点数据,5步搞定地质灾害风险区划图

本文详细介绍了使用ArcGIS进行地质灾害风险评估的完整流程,从DEM和灾害点数据出发,通过五步标准化操作生成专业风险区划图。重点讲解了信息量模型的应用,帮助读者掌握GIS技术在地质灾害易发性评价中的实践方法,提升风险评估效率与准确性。

weixin_30696427的博客 427

Spring Boot集成Quartz:实现高效、灵活的定时任务调度

在Quartz中,任务是通过实现接口来定义的。任务类的核心是execute方法,它会在任务被触发时执行。System . out . println("任务执行了:" + new java . util . Date());} }System . out . println("任务执行了:" + new java . util . Date());} }Job;import org。

2359

Fiori Elements 表格之 Tree Tables:从数据建模到交互行为的全链路剖析

SAP Fiori elements的Tree Table组件将分层数据以表格形式展示,支持展开/折叠操作,适用于组织结构、物料清单等多级数据场景。该组件在List Report和Object Page中均可使用,支持懒加载、多选、列冻结等标准表格功能,并与OData V4服务层级注解深度集成。后端需通过RAP或CAP建模提供层级数据,前端通过清单配置切换表类型。需注意在草稿模式下仅显示活动实体,且展开状态在编辑时不保留。性能方面建议采用懒加载策略,避免全量加载树节点。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 161

【人工智能】从零开始玩转龙虾(Openclaw):本地与云端(火山Arkcloud)部署全指南

龙虾(Openclaw)是一款海外智能体操作系统(agent operating system),可通过飞书机器人实现自动化办公、信息抓取、任务协作等功能。它支持本地部署和云端部署两种方式,适配MacOS和Windows系统(,建议优先使用MacOS)。sudo。

奶爸的编程之路,也就一周冷个三天 947

java定时任务与spring_Java定时任务调度器Quartz与Spring集成

在项目中经常有定时任务的功能需求。Quartz是Java中比较成熟和常用的任务调度器。Spring框架对其提供了集成。Quartz非常容易使用。一个任务调度器最基本的三个元素是Job(or Task):需要定时处理的事情Trigger: 事件触发时间点(一次性的、固定周期性的、像Linux Cron Jobs 灵活配置的)Scheduler: 调度器Job与Trigger是一对一的关系,Sched...

weixin_30140399的博客 195

数据库常见面试题(附答案)

1.事务四大特性 原子性,要么执行,要么不执行 隔离性,所有操作全部执行完以前,其它会话不能看到过程 一致性,事务前后,数据总额一致 持久性,一旦事务提交,对数据的改变就是永久的 2.数据库隔离级别,每个级别会引发什么问题,mysql默认是哪个级别 脏读:事务B读取事务A还没有提交的数据 不可重复读:两次事务读的数据不一致 幻读:事务A修改了数据,事务B也修改了数据,这时在事务A看...

csdn问鼎 46万+

Java定时任务调度器Quartz与Spring集成

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34289744的博客 132

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

从定时任务到分布式调度:Spring Boot集成XXL-Job实战指南

在现代应用开发中,定时任务和分布式调度是系统稳定性和效率的关键组成部分。Spring Boot作为当前最流行的Java开发框架,其简洁的配置和强大的生态系统为实现各类任务调度提供了便利。本文将详细介绍如何从简单的定时任务平滑过渡到企业级分布式调度,通过XXL-Job这一成熟的任务调度框架,帮助开发者构建可靠、高效的任务调度系统。 ## 一、Spring Boot定时任务基础 ### 1.1 快

gitblog_00419的博客 512

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

重学SpringBoot3-整合Quartz定时任务

Quartz 是一个开源的任务调度框架,用于在应用程序中创建、管理和调度定时任务。将 Quartz 和 Spring Boot 3 结合,可以轻松实现定时任务的灵活管理。本文将详细介绍如何在 Spring Boot 3 项目中集成 Quartz Scheduler 并实现示例任务的调度。

CoderJia的学习之路 5519

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Spring Boot集成XXL-Job:构建高可靠分布式定时任务调度中心

定时任务调度是Java应用开发中的基础技术组件,用于实现周期性或延迟性的自动化业务处理。其核心原理是通过调度器触发任务执行器,实现任务调度与业务逻辑的解耦。在分布式系统中,任务调度技术能有效解决任务冲突、失败重试和集群部署等工程难题,为数据报表统计、缓存刷新、订单超时处理等场景提供可靠支撑。XXL-Job作为轻量级分布式任务调度平台,通过调度中心与执行器分离的架构设计,提供了任务管理、负载均衡和故障恢复等企业级能力。本文将结合Spring Boot框架,详细解析XXL-Job的集成配置、任务开发和生产环境优

weixin_33692284的博客 340

spring boot 集成quartz实现定时任务调度

1.pom文件引入 &lt;dependency&gt; &lt;groupId&gt;org.quartz-scheduler&lt;/groupId&gt; &lt;artifactId&gt;quartz&lt;/artifactId&gt; &lt;version&gt;2.2.1&lt;/ver...

yjw1007020425的博客 1153

Spring与Quartz集成配置实现简单定时任务调度

可以说是最好的一篇定时任务的介绍 来自:http://www.zuidaima.com/share/2736623139458048.htm 一.代码结构图 二.核心类 Job: 一个接口, 它里面只有一个方法void execute(),我们需要执行任务就需要实现这个接口,在execute中实现我们要做的事情。 JobDetail: 在Quartz每次执行Job时,

公子七 788

Spring集成Quartz实现定时任务和异步作业调度

Quartz是开源组织OpenSymphony的一个作业调度框架,采用多线程架构,可伸缩性强,可集群扩展。Spring集成Quartz简单高效,只需实现Job接口,在方法execute()中添加业务逻辑。 本文分享Spring集成和配置Quartz的方法,并封装一个REST接口,演示项目中的实际应用。 代码文件 功能要点 Spr...

Jext技术社区 2万+

spring boot 集成quartz 定时任务调度

添加依赖: &lt;dependency&gt; &lt;groupId&gt;org.quartz-scheduler&lt;/groupId&gt; &lt;artifactId&gt;quartz&lt;/artifactId&gt; &lt;version&gt;2.2.1&lt;/version&gt; &lt;exclusions&gt;

程序员 356

Java 定时任务quartz实现方式

Java 定时任务quartz1. java自带 java.util.Timer 实现定时任务2. 使用线程池(ScheduledThreadPool-java.util.concurrent.ScheduledExecutorService)实现定时任务3. 使用注解@Scheduled实现定时任务4. 使用Quartz定时任务调度器4.1 Quartz 特点4.2 核心概念4.3 常用对象4....

雨后是冰雹 9043

分布式定时任务调度Quartz

Quartz 是 OpenSymphony 开源组织在任务调度领域的一个开源项目,完全基于 Java 实现。该项目于 2009 年被 Terracotta 收购,目前是 Terracotta 旗下的一个项目。

weixin_44519337的博客 4283
上一篇: 怒了,spring对quartz的集成偏与我作对...
下一篇: 真鬼,就是要比别人更不顺
eyejavaeye
博客等级 码龄20年 74粉丝 10原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值