弹出计划任务的错误处理

时间:2015-12-22 17:34:14

标签: java spring spring-mvc spring-scheduled

弹簧scheduler.xml

<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:task="http://www.springframework.org/schema/task"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">

<context:component-scan base-package="com.xxxx.xxxx"/>

<bean id="xmlScheduledTask" class="com.xxxx.xxxx.xxxx"/>

<task:scheduler id="taskScheduler" pool-size="10"/>

<task:scheduled-tasks>
    <task:scheduled ref="xmlScheduledTask" method="job" cron="*/10 * * * * *"/>
</task:scheduled-tasks>

我使用以下代码加载配置。

@SuppressWarnings({"resource", "unused" })  
ApplicationContext context = new ClassPathXmlApplicationContext("spring/config/spring-scheduler.xml");

有没有办法检查我的任务是否已安排好?如果xml中没有缺少计划或计划任务,是否有办法抛出错误?

0 个答案:

没有答案