相关疑难解决方法(0)

在Spring中访问计划任务

我在Spring的任务调度程序中安排了几个任务:

<task:scheduled-tasks>
    <task:scheduled ref="task1" method="run"
        cron="0 0 */0 * * *" />
    <task:scheduled ref="task2" method="run"
        cron="0 0 */30 * * *" />
</task:scheduled-tasks>

<task:scheduler id="scheduler" pool-size="10" />
Run Code Online (Sandbox Code Playgroud)

如何从应用程序上下文中访问计划任务列表并检索元信息(例如下一个执行时间)?

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler)context.getBean("scheduler");
//... how to continue from here?
Run Code Online (Sandbox Code Playgroud)

java spring scheduled-tasks

15
推荐指数
2
解决办法
1万
查看次数

标签 统计

java ×1

scheduled-tasks ×1

spring ×1