Reason:
1. @Scheduled annotation mode level is higher than resource injection level, which leads to resource injection failure
2. There is an error in the code of the scheduled task execution (just check your own code carefully)
Solution:
@Component
public class ScheduleConfig implements ApplicationContextAware {
private static ApplicationContext context;
@Override
public void setApplicationContext(@NotNull ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}
public static <T> T getBean(Class<T> clazz) {
return context != null ?context.getBean(clazz) : null;
}
}
Write a Bean to implement the ApplicationContextAware interface and rewrite the setApplicationContextAware method
It can be called in the scheduled task
Read More:
- [Solved] ERROR o.s.s.s.TaskUtils$LoggingErrorHandler – Unexpected error occurred in scheduled task.
- [Solved] Execution failed for task ‘:app:uploadCrashlyticsMappingFileRelease‘
- Doris streamload task reported an error connection reset [How to Solve]
- [Solved] android Execution failed for task ‘:app:processDebugManifest‘
- How to Solve Flynk Task Java verifyerror 209 error
- [Solved] Hive Run SQL error: mapreduce failed to initiate a task
- Initializingbean Interface & Applicationcontextaware Interface in Springboot
- Springboot WARNING: An illegal reflective access operation has occurred
- springboot jsp: There was an unexpected error (type=Not Found, status=404). No message available
- jasypt springboot Error: Error creating bean with name ‘enableEncryptablePropertySourcesPostProcessor’ defined in class path resource
- Springboot controls the startup of rabbitmq through configuration files
- Problems in springboot upgrade 2.4.0: when allowcredentials is true, allowedorigins cannot contain the specia
- [Solved] springboot Error: Error creating bean with name ‘configurationPropertiesBeans‘ defined in class path
- Springboot startup error: Field elasticsearchRestTemplate in cn.lili.modules.material.serviceImpl.QrMaterialServiceImpl required a bean of type
- [Solved] Springboot Error: Error creating bean with name ‘dataSource‘ defined in class path resource
- Uncaught SyntaxError: Unexpected token o in JSON at position 1 [How to Solve]
- SpringBoot integrates Es error: Error creating bean with name ‘restHighLevelClient‘ defined in class path resource
- [Solved] SpringBoot Project Startup Error: Field userMapper in com.demo.controller.MemberController required a bean of type ‘c
- [Solved] Springboot2.x ElasticSearch Error: availableProcessors is already set to [4], rejecting [4]
- NULL value exception occurs when freemarker renders the page globally in the springboot project