Disable Spring scheduling when running on jboss

我只是一个虾纸丫 提交于 2019-12-13 01:23:14

问题


We have a Spring 4 webapplication which use @EnableScheduling and @Scheduled.

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.

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.

Can it be something on the jboss server that turns on Spring scheduling?

Any other ideas?

TIA!

-Kaj :)


回答1:


I will suggest you to control your scheduler job via property:

@Value(..)
private boolean enabled;

@Scheduled
public void myJob() {
  if (enabled) {
    // do things
  }
}


来源:https://stackoverflow.com/questions/37112916/disable-spring-scheduling-when-running-on-jboss

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!