2010-10-05 38 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