开发者社区 问答 正文

java操作solrAPi时报错。。。?报错

代码:

public class solrQueryTest {
public static void main(String[] args) throws MalformedURLException,SolrServerException {
String baseURL="http://localhost:8983/solr";
SolrServer server=new HttpSolrServer(baseURL);
ModifiableSolrParams params=new ModifiableSolrParams();
params.set("q","平顶山" );
params.set("start", 0);
params.set("rows",5);
params.set("sort", "id desc");
params.set("f1","*");
QueryResponse response=server.query(params);
System.out.println("find"+response.getResults().getNumFound()+"\n\n");
for(SolrDocument doc:response.getResults()){
System.out.println("id"+doc.getFieldValue("id").toString());
System.out.println("sex"+doc.getFieldValue("sex").toString());
}
}
}

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.impl.conn.SchemeRegistryFactory.createSystemDefault()Lorg/apache/http/conn/scheme/SchemeRegistry;
at org.apache.http.impl.client.SystemDefaultHttpClient.createClientConnectionManager(SystemDefaultHttpClient.java:121)
at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:445)
at org.apache.solr.client.solrj.impl.HttpClientUtil.setMaxConnections(HttpClientUtil.java:201)
at org.apache.solr.client.solrj.impl.HttpClientConfigurer.configure(HttpClientConfigurer.java:33)
at org.apache.solr.client.solrj.impl.HttpClientUtil.configureClient(HttpClientUtil.java:137)
at org.apache.solr.client.solrj.impl.HttpClientUtil.createClient(HttpClientUtil.java:113)
at org.apache.solr.client.solrj.impl.HttpSolrServer.<init>(HttpSolrServer.java:168)
at org.apache.solr.client.solrj.impl.HttpSolrServer.<init>(HttpSolrServer.java:141)
at com.desgin.service.solrQueryTest.main(solrQueryTest.java:15)


展开
收起
爱吃鱼的程序员 2020-06-09 15:49:44 469 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    缺jar包  HttpClient

    params.set("q","来自洛阳的美女");/*条件也可能是来自河南的美女。。来自河南的18岁美女等*/里面包含多个关键词,,这样又是怎么搜索的。。。。谢谢,,已经解决啦!!!
    2020-06-09 15:49:59
    赞同 展开评论
问答分类:
问答标签:
问答地址: