Disable Spring scheduling when running on jboss

2019-07-24 01:19发布

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条回答
We Are One
2楼-- · 2019-07-24 01:57

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

@Value(..)
private boolean enabled;

@Scheduled
public void myJob() {
  if (enabled) {
    // do things
  }
}
查看更多
登录 后发表回答