Spring Task Demo .
来源:互联网 发布:做淘宝如何提升流量 编辑:程序博客网 时间:2024/05/22 00:41
一.web.xml
<context-param><param-name>contextConfigLocation</param-name><param-value>classpath:application*.xml</param-value></context-param><listener> <description>Spring监听器</description> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>
二.执行任务的普通Java类.
package com.test.service;import org.springframework.stereotype.Service;@Service("taskJob") public class TaskJob {public void job1(){System.out.println("任务一进行中...");}public void job2(){System.out.println("任务二进行中...");}public TaskJob() {super();System.out.println("业务类加载完成...");}}
三.applicationContext.xml.
<!-- 支持注解 --> <context:annotation-config /> <!-- 启动自动扫描,不扫描@Controller,该组件由SpringMVC配置文件扫描 --> <context:component-scan base-package="com.test.service" /> <task:scheduled-tasks> <task:scheduled ref="taskJob" method="job1" cron="0/5 * * * * ?"/> <task:scheduled ref="taskJob" method="job2" cron="0/5 * * * * ?"/> </task:scheduled-tasks>
四.启动项目
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
九月 21, 2017 5:11:17 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\DevelopTool\apache-tomcat-7.0.78\webapps\ROOT has finished in 407 ms
九月 21, 2017 5:11:17 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
九月 21, 2017 5:11:17 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
九月 21, 2017 5:11:17 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 9425 ms
任务二进行中...
任务一进行中...
任务二进行中...
任务一进行中...
任务二进行中...
- Spring Task Demo .
- spring cloud task Demo搭建
- spring task 注解+xml的demo
- spring task 定时任务 注解方式 demo
- spring task 注解+xml的demo
- spring Task
- Spring Task
- spring task
- Spring-Task
- Spring-Task
- spring task
- spring task
- Spring Task
- Spring task
- Spring Task
- Spring task
- spring task
- spring-task
- JAVA WEB报错
- curl 不支持 https
- Qt中的模型-视图
- 关于海康,宇视,天地伟业摄像头调试
- 说说Spring Cloud版本的那些事儿。
- Spring Task Demo .
- POSIX AIO及libaio的区别
- HDU 1039 Easier Done Than Said?(String模拟)
- java 反射
- js map类型
- Nexus私服以及Maven
- jar包和war包的介绍和区别
- 标签嵌套
- java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must b