对于 solr 3.5 中的基本身份验证,我使用以下代码,
String url = "http://192.168.192.11:8080/solr/FormResponses";
CommonsHttpSolrServer server = new CommonsHttpSolrServer( url );
String username = "user";
String password = "user123";
Credentials defaultcreds = new UsernamePasswordCredentials(username, password);
server.getHttpClient().getState().setCredentials(AuthScope.ANY, defaultcreds);
server.getHttpClient().getParams().setAuthenticationPreemptive(true);
在 solr 4.0CommonsHttpSolrServer
中不可用,所以我想用
HttpSolrServer
. 谁能帮我解决这个问题?