使用基本身份验证在Spring中配置HttpClient

使用基本身份验证在Spring中配置HttpClient,spring,solr,apache-commons-httpclient,Spring,Solr,Apache Commons Httpclient,我正在应用程序中实现SOLR服务器。 我们使用SolrJ包中的CommonsHttpSolrServer连接到使用CommonsHttpClient的solr服务器。 我们也使用弹簧 现在,我们的系统管理员保护了solr服务器(有充分的理由)并使用基本身份验证 如何在SolrJ中使用要注入的基本身份验证实例化HttpClient e、 g 谢谢 不幸的是,您必须使用创建客户端的工厂。身份验证所涉及的类中没有凭证的bean属性,即 HttpState.setCredentials(AuthSc

我正在应用程序中实现SOLR服务器。 我们使用SolrJ包中的CommonsHttpSolrServer连接到使用CommonsHttpClient的solr服务器。 我们也使用弹簧

现在,我们的系统管理员保护了solr服务器(有充分的理由)并使用基本身份验证

如何在SolrJ中使用要注入的基本身份验证实例化HttpClient

e、 g



谢谢

不幸的是,您必须使用创建客户端的工厂。身份验证所涉及的类中没有凭证的bean属性,即
HttpState.setCredentials(AuthScope,Credentials)
它不是bean属性


我将我的HttpClientFactory上载到。另外,

有趣的一点是
solrHttpClient
的定义,您已经忽略了这一点,这正是我要寻找的部分
<bean id="httpSolrServer" class="org.apache.solr.client.solrj.impl.CommonsHttpSolrServer">
    <constructor-arg value="${solrserver_path}" />
    <constructor-arg ref="solrHttpClient" />
</bean>