标签:
今天遇到一个工具类,需要静态注入一个属性,方法如下:
package cn.com.chinalife.ebusiness.common.util; import cn.com.chinalife.ebusiness.sys.interfacePortal.businessInterface.service.facade.InterfaceInfoService; public class EPolicyDownload { private static InterfaceInfoService interfaceInfoService; public InterfaceInfoService getInterfaceInfoService() { return interfaceInfoService; } public void setInterfaceInfoService(InterfaceInfoService interfaceInfoService) {//注意:不要加static EPolicyDownload.interfaceInfoService = interfaceInfoService; } }
<bean id="ePolicyDownLoad" class="cn.com.chinalife.ebusiness.common.util.EPolicyDownload" lazy-init="false" ></bean>
这样,在服务启动后,静态属性就被初始化了
标签:
原文地址:http://www.cnblogs.com/andong2015/p/4288850.html