[英]How do I schedule a method in a spring MVC controller?
我在配置文件中定义了各种调度程序,如下所示:
<task:executor id="xxxxxExecutor" pool-size="${async.executor.pool.size}"/>
<task:scheduler id="xxxxwwwScheduler" pool-size="1" />
<task:scheduler id="qqqqSchedular" pool-size="1" />
<task:scheduler id="lastScheduler" pool-size="1" />
我的控制器已通过@Controller注释进行了注释。 如何在Spring的@Scheduled
批注中指定特定的Scheduler
?
ps我正在尝试使用@Scheduled
注释在控制器中安排方法。
不幸的是, 不能使用多个调度程序并通过@Scheduled
注释指向它们。
但是,如果确实需要这种灵活性,则可以用XML定义作业:
<task:scheduled-tasks scheduler="myScheduler">
<task:scheduled ref="beanA" method="methodA" fixed-delay="5000"/>
</task:scheduled-tasks>
这样,您可以指定需要使用的调度程序的确切ID,然后直接引用实际任务。
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.