普通的web工程,不支持Spring,我们需要执行定时任务,那么步骤如下:
步骤1:Spring的支持,在web.xml中引入Spring的context
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
同时加入Spring的配置文件路径信息
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-*.xml</param-value> </context-param>
步骤2:Spring支持Task和注解(注解的形式)
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:task="http://www.springframework.org/schema/task" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:device="http://www.springframework.org/schema/mobile/device" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-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/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
步骤3:开发调度任务
@Service("cacheInvokeJob") public class CacheInvokeJob { /** * This method is demo */ public void demo() { //你的业务操作 } }
步骤4:设定调度cron
<mvc:annotation-driven /> <context:component-scan base-package="com.test.web.job" /> <task:scheduled-tasks> <task:scheduled ref="cacheInvokeJob" method="demo" cron="0 10 22 * * ?" /> </task:scheduled-tasks>
现在ok,可以正常执行了
相关推荐
Java Web项目加入Spring框架的简单例子,菜鸟入门使用
Spring3.0定时任务简单实例web工程 myeclipse项目 下载导入可用
本案例实现利用Spring技术实现定时任务功能,用于Web项目
Spring2.5+Quartz定时任务简单例子web工程 myeclipse 项目开发的,可直接导入运行
在Web项目中集成Spring,在Web项目中集成Spring,在Web项目中集成Spring
spring-web.jar spring-web.jar
本代码实现利用Spring实现定时任务执行功能,用于非Web项目。
jersey加入spring支持 jersey加入spring支持
最新版spring-web-5.2.3.RELEASE和spring-webmvc-5.2.3.RELEASE
Spring Web Services 官网 Spring Web Services API。 Spring Web Services 开发文档。
这个jar文件包含Web应用开发时,用到Spring框架时所需的核心类, 包括自动载入WebApplicationContext特性的类、Struts与JSF集成类、文件上传的支持类、Filter类和大量工具辅助类。 spring的核心类,提供了核心HTTP...
Building Web Apps with Spring 5 and Angular 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
spring-web.jar spring-webmvc.jar spring mvc框架需要用到的
Spring是个非常非常非常优秀的java框架,主要是用它的IOC容器帮我们依赖注入和管理一些程序中的Bean组件,实现低耦合关联,最终提高系统可扩展性和可维护性,用它来辅助我们构建web工程将会感觉非常非常非常地愉悦。...
关于Mybatis与Spring、SpringMVC整合的简单web工程,spring、springmvc 、mybatis配置文件的书写及各部分的释义。
Prepare for the Pivotal Certified Spring Web Application Developer exam and learn about Spring MVC DispatcherServlet configuration, Spring MVC programming model essentials, Spring MVC views and form ...
META-INF/MANIFEST.MF META-INF/license.txt org.springframework.remoting.caucho.BurlapClientInterceptor.class org.springframework....org/springframework/web/util/HtmlCharacterEntityReferences.properties
开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE...