要对静态变量进行注入
@Resource
private static ITecharchService techarchService;//注入为空,spring注解注入不支持静态变量注入
查资料找到可以这样注入
@Component //必须是组件,才可以用@PostConstruct
public class DDUtils{
@Resource
private ITecharchService techarchService;
private static DDUtils dd;
@PostConstruct
public void init() {
dd = this;
dd.techarchService= this.techarchService;
}
public void getA(){
//调用
dd.techarchService.getA();
}
}
更多信息请查看IT技术专栏