spring 對靜態(tài)變量進行注解
來源:易賢網(wǎng) 閱讀:4860 次 日期:2015-01-15 14:30:49
溫馨提示:易賢網(wǎng)小編為您整理了“spring 對靜態(tài)變量進行注解”,方便廣大網(wǎng)友查閱!

要對靜態(tài)變量進行注入

@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();

}

}

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)絡(luò)編程
下一篇:通用函數(shù)
易賢網(wǎng)手機網(wǎng)站地址:spring 對靜態(tài)變量進行注解
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權(quán)所有:易賢網(wǎng)