我在 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" />
如何访问计划任务列表并从应用程序上下文中检索元信息(例如下一次执行时间)?
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler)context.getBean("scheduler");
//... how to continue from here?
最佳答案
Spring 中没有公共(public) API 可以做到这一点。
相关:
https://stackoverflow.com/questions/25017691/
相关文章:
java - 我可以在 View 层中找到 spring mvc Controller 的 URL
java - Spring @Transaction 未启动事务
java - 层次树角色的 Spring Security/Java EE 解决方案
java - 在没有 Spring 身份验证的情况下通过 web-socket 多次回复
java - 如何在 Hibernate 中使用临时表批量删除记录?
java - 在哪里以及如何处理 spring+hibernate 异常?
java - 为什么 PropertyDescriptor 行为从 Java 1.6 更改为 1.7