Spring註解沒法注入靜態變量

參考:https://blog.csdn.net/BuquTianya/article/details/49009831app

1.使用xml方式聲明Bean,在xml中注入靜態變量; spa

  
2.使用一個非靜態的變量注入,而後在@PostConstruct標記的方法中給靜態變量賦值。.net

3,在靜態方法中獲取beancode

AppConfMapper appConfMapper = (AppConfMapper) BeanHoldFactory.getApplicationContext().getBean("appConfMapper");

 4,給靜態變量設置Setter方法,在Setter方法上加註入操做就能夠了xml

相關文章
相關標籤/搜索