我已经写了下面提到的代码。
HttpSolrServer solrServer = new HttpSolrServer("http://10.40.4.171/solr/prime-core");
List<UserSolr> userList=null;
SolrQuery q = new SolrQuery();
q.setQuery("*:*");
q.setStart(0);
q.setRows(10);
//SolrDocumentList results = null;
try {
QueryResponse response = solrServer.query(q);
userList=response.getBeans(UserSolr.class);
} catch (Exception e) {
// TODO: handle exception
System.out.println(e);
}但对于上述情况,我得到以下错误:-
org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Server at http://10.40.4.171/solr/prime-core returned non ok status:407, message:Proxy Authorization Required我解决不了这个问题。同样的代码与url http://localhost:8080/solr/prime-core运行良好,请让我知道如何修改,以连接到服务器,没有错误。
谢谢。
注意:主核心是我的Solr核心,我正在使用Solr 4.3
发布于 2013-07-29 12:07:03
HTTP代码407意味着Proxy Authentication Required,您需要在通过HttpClient连接到服务器时设置身份验证信息。
httpclient.getCredentialsProvider().setCredentials(
AuthScope.ANY,
new UsernamePasswordCredentials(username, password));
solrServer = new HttpSolrServer(solrUrl, httpclient);//with credentials您可以查看类似的讨论:
Solr - instantiate HttpSolrServer with Httpclient Solr 4 with basic authentication
https://stackoverflow.com/questions/17923476
复制相似问题