Spring 定时任务的配置
1.applicationContext.xml 中 加入task 的声明与xsd
|
1
|
xmlns:task="http://www.springframework.org/schema/task" |
|
1
|
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd |
配置中加入
|
1
|
<task:annotation-driven/> |
这个是用来启用自动的注解解析。
2.编写POJO
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
@Component public class DailyPiracyJob { @Scheduled(cron = "0 0 23 * * ?") public void print() throws Exception { system.out.println(干点你想干的事!); } } |
@Compont 注解,是让Spring context 可以扫描到,并自动注入需要的bean
@Scheudle 核心注解,不能有返回值,cron是定义了任务运行的间隔,具体,请参考网上其他教程
需要注意的是,在applicationContext.xml中不能启用 default-lazy-init=“true”,否则注解会失效
Spring 定时任务的配置的更多相关文章
- spring定时任务的配置
定时任务配置分为三个步骤: 1.定义任务 2.任务执行策略配置 3.启动任务 1.定义任务 <!--要定时执行的方法--> <bean id="testTaskJob&qu ...
- spring定时任务的配置使用
spring的定时任务配置分为三个步骤: 1.定义任务 2.任务执行策略配置 3.启动任务 1.定义任务 <!--要定时执行的方法--> <bean id="testTas ...
- spring 5.x 系列第22篇 —— spring 定时任务 (代码配置方式)
源码Gitub地址:https://github.com/heibaiying/spring-samples-for-all 一.说明 1.1 项目结构说明 关于任务的调度配置定义在ServletCo ...
- spring 5.x 系列第21篇 —— spring 定时任务 (xml配置方式)
源码Gitub地址:https://github.com/heibaiying/spring-samples-for-all 一.说明 1.1 项目结构说明 关于任务的调度配置定义在springApp ...
- spring定时任务的配置式与注解式
在定时任务配置文件中添加内容: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi=&q ...
- spring 定时任务参数配置详解
注:本文摘自<Quartz Cron 触发器 Cron Expression 的格式>http://blog.csdn.net/yefengmeander/article/details/ ...
- spring定时任务配置,以及不执行的解决办法
前几天,同事问了我一个问题,我告诉他用spring的定时任务解决,并给他配置了spring的定时任务.当时随便找了一个bean写了一段代码,验证定时任务正确执行后,就没再管,昨天下午,同事写代码的时候 ...
- spring 定时任务配置
1.(易)如何在spring中配置定时任务? spring的定时任务配置分为三个步骤: 1.定义任务 2.任务执行策略配置 3.启动任务 (程序中一般我们都是到过写的,直观些) 1.定义任务 < ...
- spring Quartz多个定时任务的配置
Quartz多个定时任务的配置 1,配置文件与spring整合,需要在spring 的总配置中一入或者在web.xml中spring监听中加上 ztc_cp-spring-quartz.xml 注:定 ...
随机推荐
- Andriod 字符串数组里加入字符串元素
private String[] t1 = { "姓名", "性别", "年龄", "居住地","邮箱&quo ...
- hiho 第1周 最长回文子串
题目链接:http://hihocoder.com/problemset/problem/1032 #include <bits/stdc++.h> using namespace std ...
- 2016年10月14日 星期五 --出埃及记 Exodus 18:25
2016年10月14日 星期五 --出埃及记 Exodus 18:25 He chose capable men from all Israel and made them leaders of th ...
- MVC系列之一 入门概述
一 概述 MVC作为一种当前比较好的开发web的框架,不得不提一下了,和WebForm比较来看,有了很大的进步和改进. 先进行一个简单的比较,两个都是Web开发框架,理念仍然是较快速开发. 不过MVC ...
- 【leetcode❤python】Move Zeroes
#-*- coding: UTF-8 -*- #filter()函数可以对序列做过滤处理,就是说可以使用一个自定的函数过滤一个序列,#把序列的每一项传到自定义的过滤函数里处理,并返回结果做过滤.最终一 ...
- BZOJ 2568 比特集合
题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=2568 题意:维护一个集合S,支持以下操作: (1)INS M : 将元素 M 插入 ...
- 02.iOS开发网络篇—HTTP协议
iOS开发网络篇—HTTP协议 说明:apache tomcat服务器必须占用8080端口 一.URL 1.基本介绍 URL的全称是Uniform Resource Locator(统一资源定位符) ...
- Cheatsheet: 2013 06.01 ~ 06.22
.NET Git for Visual Studio and .NET developers How to download multiple files concurrently using Web ...
- Using Text_IO To Read Files in Oracle D2k
Suppose you want to read a file from D2k client and want to store its content in Oracle database. Bu ...
- Creating Dynamic LOV in Oracle D2k Forms
Dynamic Lov is a good idea for the form where too many Lov requirement is there with different recor ...