在javaweb项目中,经常用到定时器功能,这里介绍两个我使用过的解决方案,分别是:scheduler 和 quartz。
scheduler:
需要在spring.xml配置文件中添加关于task的配置:
<beans xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd">
<task:executor id="executor" pool-size="5" />
<task:scheduler id="scheduler" pool-size="10" />
<task:annotation-driven executor="executor" scheduler="scheduler" />
<!-- 上下两种选一个就可以,区别:标配和简配-->
<task:annotation-driven/>
PSÿ
scheduler:
需要在spring.xml配置文件中添加关于task的配置:
<beans xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd">
<task:executor id="executor" pool-size="5" />
<task:scheduler id="scheduler" pool-size="10" />
<task:annotation-driven executor="executor" scheduler="scheduler" />
<!-- 上下两种选一个就可以,区别:标配和简配-->
<task:annotation-driven/>
PSÿ