I solved this, here is what I did for future reference:
- Removed @EnableScheduling annotation from my application
- Added a new configuration class and conditional for enabling / disabling scheduling based on application property
-
@Configuration public class Scheduler { @Conditional(SchedulerCondition.class) @Bean(name = TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public ScheduledAnnotationBeanPostProcessor scheduledAnnotationProcessor() { return new ScheduledAnnotationBeanPostProcessor(); } }
And conditional class
public class SchedulerCondition implements Condition { @Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { return Boolean.valueOf(context.getEnvironment().getProperty("com.myapp.config.scheduler.enabled")); } }
Alternatively, to disable the web server on the backend server, simply add the following to the application.properties file:
spring.main.web_environment=false
source share