要對(duì)靜態(tài)變量進(jìn)行注入
@Resource
private static ITecharchService techarchService;//注入為空,spring注解注入不支持靜態(tài)變量注入
查資料找到可以這樣注入
@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(){
//調(diào)用
dd.techarchService.getA();
}
}
更多信息請(qǐng)查看IT技術(shù)專欄