0

spring-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 中没有计划或计划任务,有没有办法抛出错误?

4

0 回答 0