spring注入原型bean
<bean id="httpClient" class="org.apache.commons.httpclient.HttpClient" scope="prototype" />
String ifmSwitch = ConfigDataRepository.getInitialDatas().get(ConfigurationConstants.IFM_SWITCH);
HttpClient client = null;
if(ifmSwitch == null || ifmSwitch.equals("0")){
client = new HttpClient();
} else {
client = (HttpClient) SpringContext.getBean("httpClient");
}
用@Autowired注入还是单例从上下文中获取bean是原型