将定时器用到的quartz.jar放在lip文件下

quartz.xml文件(完整)

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<!--映射-->
<bean id= "TimedTask" class ="com.blue.yanxishe.service.timer.TimedTask"/>
<!--自动推送跟踪日志3天未跟新提醒-->
<bean id="autoTailLogRemind" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="TimedTask"/>
<property name="targetMethod" value="autoTailLogRemind"/>
</bean>
<bean id="autoTailLogRemindTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="autoTailLogRemind"/>
<property name="cronExpression" value="0 0 0 * * ?"/>
</bean>

<!--自动推送排期逾期提醒-->
<bean id="autoScheduOverdueRemind" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> //定义JobDetail,即定时任务
<property name="targetObject" ref="TimedTask"/> //目标类是TimeTask
<property name="targetMethod" value="autoScheduOverdueRemind"/> //目标方法时TimeTask类下的autoScheduOverueRemind方法
</bean>
<bean id="autoScheduOverdueRemindTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> //配置触发条件
<property name="jobDetail" ref="autoScheduOverdueRemind"/> //关联需要执行的任务
<property name="cronExpression" value="0 0 0 * * ?"/> //设置定义条件,这里"0 0 0 * * ?",表示每天00:00执行一次
</bean>
<!-- 启动触发器的配置开始-->
<bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="autoTailLogRemindTrigger" /> //关联需要执行的任务设置
<ref bean="autoScheduOverdueRemindTrigger" />
</list>
</property>
</bean>

</beans>

 web.xml(部分) 

	<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring/context.xml
classpath:spring/context-shiro.xml
classpath:spring/context-redis.xml
classpath:spring/quartz.xml
</param-value>
</context-param>

  TimedTask.java(完整)

package com.blue.yanxishe.service.timer;

import java.io.Serializable;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.blue.common.exception.ServerSqlErrorException;
import com.blue.yanxishe.service.shop.ShopMessageService; @Service
public class TimedTask implements Serializable{ @Autowired
private ShopMessageService shopMessageService; public void autoTailLogRemind() throws ServerSqlErrorException{
shopMessageService.getTailLogRemind();
System.out.println(" getTailLogRemind() was running!!");
} public void autoScheduOverdueRemind() throws ServerSqlErrorException{
shopMessageService.getScheduOverdueRemind();
System.out.println(" getScheduOverdueRemind() was running!!");
}
}

  

  

项目总结08:spring quartz 定时器Demo的更多相关文章

  1. 启用Spring quartz定时器,导致tomcat服务器自动停止

    在项目中添加了一个定时功能,基于Spring quartz: 设置好执行时间后(如:每天14:00) 当程序执行完后,就会出现以下信息: 2013-7-22 11:36:02 org.apache.c ...

  2. Spring Quartz定时器 配置文件详解

    在JavaEE系统中,我们会经常用到定时任务,比如每天凌晨生成前天报表,每一小时生成汇总数据等等.我们可以使用java.util.Timer结合java.util.TimerTask来完成这项工作,但 ...

  3. spring quartz 定时器时间格式设置

    "0/10 * * * * ?" 10秒执行一次 "0 0 12 * * ?"每天中午十二点触发"0 15 10 ? * *"每天早上10: ...

  4. 关于Spring的Quartz定时器设定

    在实际的开发业务中经常会遇到定时执行某个任务,如果项目使用的ssh框架的话,就需要配合spring来使用定时器.spring的定时器是一个固定的配置格式,具体的applicationContext配置 ...

  5. spring启动quartz定时器

    在很多中经常要用到定时任务,quartz是定时器中比较好用的,在Spring中使用quartz是很容易的事情,首先在spring的applicationContext.xml文件中增加如下配置: &l ...

  6. Spring+quartz集群解决多服务器部署定时器重复执行的问题

    一.问题描述 Spring自带的Task虽然能很好使用定时任务,只需要做些简单的配置就可以了.不过如果部署在多台服务器上的时候,这样定时任务会在每台服务器都会执行,造成重复执行. 二.解决方案 Spr ...

  7. Spring的quartz定时器同一时刻重复执行二次的问题解决

    最近用Spring的quartz定时器的时候,发现到时间后,任务总是重复执行两次,在tomcat或jboss下都如此. 打印出他们的hashcode,发现是不一样的,也就是说,在web容器启动的时候, ...

  8. java定时器,Spring定时器和Quartz定时器

    一.java定时器的应用 其实java很早就有解决定时器任务的方法了,java提供了了类java.util.TimerTask类基于线程的方式来实现定时任务的操作,然后再提供java.util.Tim ...

  9. java Quartz定时器任务与Spring task定时的几种实现,

    java Quartz定时器任务与Spring task定时的几种实现 基于java 的定时任务实现, Quartz 时间详细配置    请查阅   http://www.cnblogs.com/si ...

随机推荐

  1. jinjia

    https://www.cnblogs.com/dachenzi/p/8242713.html

  2. select as table

    select order_time, max(sum_price) from (SELECT order, sum(price) as sum_price FROM orders group by o ...

  3. Nginx缓存配置以及nginx ngx_cache_purge模块的使用

    web缓存位于内容源Web服务器和客户端之间,当用户访问一个URL时,Web缓存服务器会去后端Web源服务器取回要输出的内容,然后,当下一个请求到来时,如果访问的是相同的URL,Web缓存服务器直接输 ...

  4. python笔记之强制函数以关键字参数传参

    最近学习python,学到了函数传参,看到了以下这个特殊情况,特此来做个笔记 def add(*, x, y): print(x, y) 以上函数定义后,该怎么传参?前面的那个*号是做什么用的? 我们 ...

  5. [原创]delphi在win7下创建共享文件夹源代码

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  6. NGINX安全

    http://anyun.org/a/jishuguanzhu/WEBjishu/2017/0804/8721.html

  7. Logo tools

    http://www.cilogo.com/LOGO/

  8. ubuntu14.04后安装win10记录

    1首先修改启动引导顺序,从U盘启动, 2自动安装,产生一个问题,gpt分区无法安装,解决方法,感谢https://jingyan.baidu.com/article/08b6a591c82df414a ...

  9. 使用 COM 类库创建链接桌面快捷方式

    用到的 COM 类库: Windows Script Host Object Model --> Interop.IWshRuntimeLibrary.dll 示例代码: private sta ...

  10. mongodb从入门到精通

    1.mongodb官网下载文件2.安装mongodb 3.配置安装成服务 4.记得连接的时候修改连接的ip地址 5.显示当前使用的数据库名——dbs 6.查找所有数据库——show dbs 7.查找所 ...