Spring:安排一个带有参数的任务 [英] Spring : Schedule a task which takes a parameter
本文介绍了Spring:安排一个带有参数的任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个具有以下功能的类:
I have a class with the following function:
public class classA{
...
...
void function_to_be_scheduled(String param){
...
...
}
}
我想使用任务命名空间的 schedule-tasks 元素来调度函数.
I want to schedule the function using the scheduled-tasks element of the task namespace.
<task:scheduled-tasks>
<task:scheduled ref="beanA" method="function_to_be_scheduled" cron="${cron}"/>
</task:scheduled-tasks>
如何将参数传递给我想要调度的函数?
How do i pass the parameter to the function which i want to schedule?
推荐答案
根据文档 你不能.
注意要调度的方法必须有void返回和不能期待任何参数.
Notice that the methods to be scheduled must have void returns and must not expect any arguments.
这篇关于Spring:安排一个带有参数的任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文