Spring定时器XML配置
spring-task.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"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.1.xsd"> <!-- springMVC 定时器开关 -->
<task:annotation-driven />
<bean id="midTask" class="com.henu.task.MidTask"></bean>
<task:scheduled-tasks>
<task:scheduled ref="midTask" method="timerController" cron="0/5 * * * * ?" /> <!-- 这里表示的是每隔5秒执行一次 -->
</task:scheduled-tasks>
</beans>
web.xml(在web.xml中加入以下代码)
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/spring-task.xml</param-value>
</context-param>
MidTask.java
package com.henu.task;
public class MidTask {
public void timerController() {
System.out.println("task1");
}
}
Spring定时器XML配置的更多相关文章
- [spring-framework]Spring定时器的配置和使用
开发中我们常常会做一些定时任务,这些任务有开始时间,并会按一定的周期或规则执行.如此我们在Java程序开发中使用定时器来处理定时任务. <!-- MessageRequestTask类中包含了m ...
- spring的xml配置声明以及相应的问题处理
spring的xml配置声明: xml配置声明 Code 问题处理 问题1 xml报错: cvc-elt.1: Cannot find the declaration of element 'bea ...
- spring+mybaits xml配置解析----转
一.项目中spring+mybaits xml配置解析 一般我们会在datasource.xml中进行如下配置,但是其中每个配置项原理和用途是什么,并不是那么清楚,如果不清楚的话,在使用时候就很有可能 ...
- spring中用xml配置构造注入的心得
spring中用xml配置构造注入时,如果 <constructor-arg> 属性都是 ref ,则不用理会参数顺序 <constructor-arg ref="kill ...
- spring定时器的配置
首先,新建一个java项目,下面导入需要的jar包: 这里有你需要的jar包哦. jar包下载 在src文件夹下,新建一个applicationContext.xml文件 <?xml versi ...
- Spring 中 Xml配置文件属性的说明
Xml配置文件属性的说明: <bean id="TheAction" ⑴ class="net.xiaxin.spring.qs.UpperAction" ...
- Spring,SpringMvc配置常见的坑,注解的使用注意事项,applicationContext.xml和spring.mvc.xml配置注意事项,spring中的事务失效,事务不回滚原因
1.Spring中的applicationContext.xml配置错误导致的异常 异常信息: org.apache.ibatis.binding.BindingException: Invalid ...
- Spring 基于XML配置
基于XML的配置 对于基于XML的配置,Spring 1.0的配置文件采用DTD格式,Spring2.0以后采用Schema格式,后者让不同类型的配罝拥有了自己的命名空间,使得配置文件更具扩展性.此外 ...
- spring ioc xml配置
一个完整的spring xml配置:是把action,service,dao以及其它的资源性配置(如basedao)和公共性配置(如连接数据库)配置在resource.xml中,这样就有四个xml配置 ...
随机推荐
- 【.NET】学习SQLite(1)
前沿 SQLite,是一款轻型的数据库,是遵守ACID的关系型数据库管理系统,它的设计目标是嵌入式的,而且目前已经在很多嵌入式产品中使用了它,它占用资源非常的低,在嵌入式设备中,可能只需要几百K的内存 ...
- 【转】Vue v-bind与v-model的区别
v-model 指令在表单控件元素上创建双向数据绑定,所谓双向绑定,指的就是我们在js中的vue实例中 的data与其渲染的dom元素上的内容保持一致,两者无论谁被改变,另一方也会相应的更新为相同的数 ...
- vue 阻止事件冒泡
<mt-button type="danger" size="small" @click="cancelOrderInfo(this.even ...
- PHP函数声明(三)
/** * 一.任何参数的数量 * func_get_args()//接收一个数组,数组里面包含所有参数 * func_num_args()//取得共有几个参数 * func_get_arg(整数)/ ...
- 【BZOJ 2298】 2298: [HAOI2011]problem a (DP)
2298: [HAOI2011]problem a Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 1326 Solved: 637 Descript ...
- 51Nod1140 矩阵相乘的结果
随机化算法. A*B==C那么X*A*B==X*C 降到了n*n复杂度. 多次随机X判断即可. By:大奕哥 #include<bits/stdc++.h> using namespace ...
- loj2480 [CEOI2017]One-Way Streets 边双+树上差分
边双无法确定 缩完边双就是一棵树 树上差分随意弄一下吧... #include <vector> #include <cstdio> #include <cstring& ...
- session_write_close() 用法
1.需要session控制的大文件下载,防止因为占用session文件时间太久,导致其他页面的session无法执行 session_write_close() worked as a lifesav ...
- @SuppressWarning 抑制警告注解
@SuppressWarning 抑制警告注解 Java.lang.SuppressWarnings 是 J2SE5.0中标准的Annotation 之一. 可以标注在类,字段,方法,参数,构造方法, ...
- bozj 1449/2895: 球队预算 -- 费用流
2895: 球队预算 Time Limit: 10 Sec Memory Limit: 256 MB Description 在一个篮球联赛里,有n支球队,球队的支出是和他们的胜负场次有关系的,具体 ...