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是原型

posted @ 2017-09-22 16:28  tonggc1668  阅读(315)  评论(0编辑  收藏  举报