一、静态方法调用service
@Autowired
private XXXXService xXXXService;
在静态方法中用得保证xXXXService是静态的,但是上面这句不是,加了static之后也没办法正常获取xXXXService = null
@Autowired
private XXXXrService xXXXService;
private static XXXXrService service;
@PostConstruct
public void init() {
service= this.xXXXService;
}
二、静态方法调用@Value
同上
@Value("${idScopoeFile}")
private String idScopoeFile;
private static String idScopeFileStatic;
@PostConstruct
public void init() {
service= this.xXXXService;
idScopeFileStatic = this.idScopoeFile;
}