问题
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