一、创建web项目
    项目名称:springtaskdemo1
二、添加支持
    1.在lib包添加spring支持
        commons-logging.jar
        slf4j-api-1.6.1.jar
        spring-beans-3.2.0.RELEASE.jar
        spring-context-3.2.0.RELEASE.jar
        spring-context-support-3.2.0.RELEASE.jar
        spring-core-3.2.0.RELEASE.jar
        spring-expression-3.2.0.RELEASE.jar
        spring-tx-3.2.0.RELEASE.jar
        spring-web-3.2.0.RELEASE.jar
三、添加配置文件
    1.在项目中创建conf目录
        /conf
    2.在conf目录下创建配置文件
        配置文件名称:applicationContext.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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
                xmlns:task="http://www.springframework.org/schema/task"
                xsi:schemaLocation="
                http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
                http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
            </beans>
四、修改web.xml文件,添加如下配置
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
五、创建任务类
    1.在src下创建包
        包名:cn.jbit.springtaskdemo1.job
    2.在包创建任务类
        类名:SpringTaskJob.java
        类内容:
            public class SpringTaskJob {
                public void run(){
                    System.out.println("run");
                }
            }
六、配置任务类
    <bean id="taskjob" class="cn.jbit.springtaskdemo1.job.SpringTaskJob"></bean>
    <task:scheduled-tasks>
        <task:scheduled ref="taskjob" method="run" cron="0 17 10 * * ?"/>
    </task:scheduled-tasks>
七、部署并启动服务

转载于:https://blog.51cto.com/suyanzhu/1566583

spring自带任务调度-xml方式相关推荐

  1. Spring IoC和DI XML方式 注解方式 依赖注入 AOP面向切面

    初识Spring框架 时代变迁 原始时代我们用一个jsp搞定一切,但如此开发大型项目时我们遇到了问题,前端美化的代码和后端的代码交织,代码中又有html.js.css样式,又有业务逻辑和数据库访问代码 ...

  2. web.xml中,spring模块化加载xml方式

    1:web.xml中添加监听器. <listener><listener-class>org.springframework.web.context.ContextLoader ...

  3. 2.Spring【DI】XML方式

    依赖: 在A类中引用了B类,说明A依赖于B. 注入: 使用Spring框架给A类中的B对象的属性赋值. 直接上代码: 1.只使用IOC public class Person {private Str ...

  4. spring AOP解析之xml方式详解

    <aop:config>标签解析 aop名称空间的解析器是AopNamespaceHandler // 这里我们可以看到注册了几个解析器,重点关注ConfigBeanDefinitionP ...

  5. Spring——Bean管理-xml方式进行属性注入

    目录 一.xml方式创建对象 二.xml方式注入属性 第①种方式注入:set方法注入 第②种方式注入:有参构造函数注入 constructor-arg:通过构造函数注入 用name标签属性: 不按照顺 ...

  6. 任务调度的方式:Timer、ScheduledExecutorService、spring task、quartz、XXL-JOB、Elastic-Job

    任务调度 定时任务调度:基于给定的时间点.给定的时间间隔.给定的执行次数自动执行的任务. Timer 介绍 Timer,简单无门槛,一般也没人用. Timer位于java.util包下,其内部包含且仅 ...

  7. Spring Bean、XML方式Bean配置、Bean实例化配置、Bean注入

    文章目录 Bean管理 一.SpringBoot Bean 初了解 1.1 了解 1.2 Bean的作用域 1.2.1 注意事项 1.3 第三方Bean 二. 基于XML方式Bean的配置 2.1 S ...

  8. Spring学习笔记:2(IOC装配Bean之xml方式)

    xml配置方式装配Bean 本文借鉴于:https://www.cnblogs.com/qdhxhz/p/6511887.html Spring框架Bean实例化的方式提供了三种方式实例化Bean 构 ...

  9. Spring中加载xml配置文件的六种方式

    Spring中加载xml配置文件的六种方式 博客分类: Spring&EJB XMLSpringWebBeanBlog  因为目前正在从事一个项目,项目中一个需求就是所有的功能都是插件的形式装 ...

最新文章

  1. Tomcat unable to start within 45 seconds.
  2. 计算机与人脑的异同作文,小学信息技术3-6年级全册教案.pdf
  3. leetcode538. 把二叉搜索树转换为累加树
  4. 常用算法一(分治算法)
  5. python的诞生和发展历史_Python发展史-一门编程语言的起源
  6. 华为手机短息没有声音解决方案
  7. DeFi 协议 Benchmark Protocol 启动第二阶段流动性挖矿计划 The Press
  8. Microsoft Updater Application Block 1.2.1 核心设计(core design) [翻译]
  9. samba add new smbpasswd recycle
  10. 解决windows下使用pycharm的anaconda安装numpy或tensorflow不成功的问题
  11. Atitit 图像处理类库大总结attilax qc20
  12. 夏昕.深入浅出Hibernate中的第一个例子体会.
  13. 《摄影测量学》空间后方交会详细解读
  14. html5显示文件后缀,如何显示文件后缀名
  15. 32768HZ晶振不起振
  16. html验证座机号码_JS校验手机号 座机 邮箱 微信号
  17. [46]python画出心形图
  18. python编写的动物识别专家系统_基于Python的动物识别专家系统
  19. Macbook 安装VMware专业版
  20. LeetCode40 Combination Sum II 解析

热门文章

  1. rails将类常量重构到数据库对应的表中之二
  2. 简单介绍Javascript匿名函数和面向对象编程
  3. 一打开excel表,总提示有4.0版的宏
  4. 安卓拍照上传php服务器,Android拍照上传至PHP服务器并写入MySql数据库(下)
  5. 监听屏幕解锁和判断屏幕状态
  6. Hibernate JPA中insert插入数据后自动执行select last_insert_id()解决方法
  7. Java异常处理 一
  8. 高效的java异常处理
  9. Python基础:文件的操作
  10. dfs Codeforces Round #356 (Div. 2) D