要對靜態變量進行注入
@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();
}
}