spring 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:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
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">
<!-- 配置任务线性池 -->
<task:executor id="executor" pool-size="3" />
<task:scheduler id="scheduler" pool-size="3" />
<!-- 启用annotation方式 -->
<task:annotation-driven scheduler="scheduler"
executor="executor" proxy-target-class="true" />
<task:scheduled-tasks scheduler="scheduler">
<!-- 资产信息匹配 -->
<task:scheduled ref="jobTest" method="dowork" cron="0/5 * * * * ?" />
</task:scheduled-tasks>
</beans>
任务类:
@Component
public class JobTest {
public void dowork() {
System.out.print("111111111111111111")
}
}