问题描述
我们有一个使用@EnableScheduling
和@Scheduled
的Spring 4 Web应用程序.
We have a Spring 4 webapplication which use @EnableScheduling
and @Scheduled
.
在某些测试服务器上,我们不希望调度活动.我们通过在配置中添加带有@EnableScheduling
批注的配置文件来解决了这个问题.
On some of our testservers we don't want scheduling to be active. We have solved this by adding a profile to the configuration that have the @EnableScheduling
annotation.
在Mac上的码头上运行时正常运行.在jboss(EAP 6.3)上运行时,即使我删除了@EnableScheduling
批注,也会启用计划.
When running on jetty on my mac that works fine. When running on jboss (EAP 6.3) scheduling is enabled even if I delete the @EnableScheduling
annotation.
是否可以在jboss服务器上启动Spring调度?
Can it be something on the jboss server that turns on Spring scheduling?
还有其他想法吗?
TIA!
-Kaj:)
推荐答案
我建议您通过属性控制调度程序作业:
I will suggest you to control your scheduler job via property:
@Value(..)
private boolean enabled;
@Scheduled
public void myJob() {
if (enabled) {
// do things
}
}
这篇关于在jboss上运行时禁用Spring调度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!