Use the global timing task-cronutil in the Hutool utility class
Spring’s @Autowired annotation is used to inject the required service. When the add method in the service is called, the program raises a null pointer exception. In the thread, it is thread-safe, injection-resistant, and is resolved by the context object instance
package com.backstage.config;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/
* * * @ ProjectName:
* @ Package: com. Runs backstage. Config
* @ the ClassName: ApplicationContextProvider
* @ Description: get bean object tools
* @ Author: wangzhilong @ CreateDate
* :
* @version: 1.0
/
Author: * *
* ZhuShangJin Date:
* 2018/7/3/
* @ Component
public class ApplicationContextProvider implements ApplicationContextAware {
/* * *
the context object instance */
private static ApplicationContext ApplicationContext;
@Override
public void setApplicationContext(ApplicationContext) throws BeansException {
is.ApplicationContext = ApplicationContext;
}
/**
* @return
@return
* @return
publ>tatic ApplicationContext getApplicationContext() {
}
/* * * by the name for the Bean.
* * * @ @ param name
the return/
* public static Object getBean (String name) {
the return getApplicationContext().getBean(name);
}
/
* * * by class get beans.
* * @ param clazz
* @ param & lt; T>
* @ return/
* public static & lt; T> T getBean(Class< T> Clazz) {
return getApplicationContext () getBean (clazz);
}
/ * *
* by name, and the return of the Clazz specified Bean
* * @ param name
* @ param Clazz
* @ param & lt; T>
* @ return/
* public static & lt; T> T getBean(String name, Class< T> Clazz) {
return getApplicationContext().getBean(name, clazz);
}
Public TimingMonitoring () {//new injection need bean enclosing detailedDataService = ApplicationContextProvider. GetBean (detailedDataService. Class); }
}
Read More:
- Several implementation methods of Python timing task
- Quarz timing task does not execute and does not report error
- Jenkins appears error: error cloning remote repo ‘origin solution (set global tool configuration)
- Springboot integrates quartz timing tasks
- Error c2951: template declaration can only be used at the global, namespace, or class scope. Error c2598: link specification must be at the global scope
- Error: global variable is ambiguous (conflict between using namespace STD and global variable)
- Hive execution task report cannot find main class error
- Python global variables and global keywords
- Register global time filter in main.js in Vue
- How to read JS file app.ux Global variables in
- The solution to the error of inheriting httpservlet in idea tool
- The differences between the equals method in the string class and the equals method in the object class
- How to install postman tool in Ubuntu 16.04
- Error in the latest version of ffmpeg: ‘codec’_ FLAG_ GLOBAL_ Header ‘undeclared identifier solution
- Elasticsearch in Spring uses Spel to dynamically create Index of Documet class
- How to Fix error reported by rqt_plot tool in ROS
- Unable to find utility “instruments”, not a developer tool or in PATH
- [Solved] vivado Install Error: Xilinx Design Tool Display in Red
- Error inflating class in WebView in Android 5. X android.webkit.WebView Solutions