在jboss上运行时禁用Spring调度 [英] Disable Spring scheduling when running on jboss

查看:98
本文介绍了在jboss上运行时禁用Spring调度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个使用@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调度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆