<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.2.xsd"> <!-- 定时器 --> <task:scheduler id="scheduler" pool-size="10" /> <task:executor id="executor" keep-alive="3600" pool-size="100-200" queue-capacity="500" rejection-policy="CALLER_RUNS" /> <task:annotation-driven executor="executor" scheduler="scheduler" /> // @Scheduled(fixedRate = 2000) @Scheduled(cron = "2 40 17 * * ?") public void task1() { Date cTime = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String str = sdf.format(cTime); System.out.println(str); } Spring3 中的Schedule Task Cron表达式 Cron表达式使用格式
每个符号代表的含义:
实用的例子 表达式 含义
|
SpringMVC定时器
最新推荐文章于 2022-03-21 16:17:34 发布
第一步导入jar包:
第二步书写配置springmvc.xml