一,使用spring的注解从而使用依赖注入注入。
@Component
public class SynchroDataQuartz
二,使用@Autowired注解注入需要用到的bean。
@Autowired
private InstitutionService institutionService;
@Autowired
private UserService userService;
三,使用本类中加载静态的方式获取自己。
public static SynchroDataQuartz synchroDataQuartz;
四,使用@PostConstruct注解和重写init方法使其初始化时注入。
@PostConstruct
public void init(){
synchroDataQuartz = this;
synchroDataQuartz.userService = this.userService;
synchroDataQuartz.institutionService = this.institutionService;
}
注:该类一定要背spring主动注入扫描到