2010-10-05 69 views
0

我在我们的应用程序中实现了SOLR服务器。 我们使用SolrJ软件包中的CommonsHttpSolrServer连接到使用commons-httpclient的solr服务器。 我们也使用Spring。使用基本身份验证在Spring中配置HttpClient

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

我怎样才能实例化一个HttpClient与基本身份验证注入SolrJ?

例如

<bean id="httpSolrServer" class="org.apache.solr.client.solrj.impl.CommonsHttpSolrServer"> 
    <constructor-arg value="${solrserver_path}" /> 
    <constructor-arg ref="solrHttpClient" /> 
</bean> 

谢谢!

+0

有趣的是'solrHttpClient'的定义,你已经把它留下 – skaffman 2010-10-05 15:38:34

+0

这正是我寻找的部分 – 2010-10-11 08:13:22

回答

1

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

我上传了我的HttpClientFactory到github。 Se也是snippet for the spring context

相关问题