繁体   English   中英

线程“ main”中的异常java.lang.NoClassDefFoundError:org / apache / http / NoHttpResponseException

[英]Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/http/NoHttpResponseException

以下代码用于“使用SolrJ进行搜索”。 运行代码时显示此错误。

IDE是netbean。

public static void main(String[] args) throws MalformedURLException, SolrServerException {
**HttpSolrServer solr = new HttpSolrServer("http://localhost:8983/solr");**

SolrQuery query = new SolrQuery();
query.setQuery("sony digital camera");
query.addFilterQuery("cat:electronics","store:amazon.com");
query.setFields("id","price","merchant","cat","store");
query.setStart(0);    
query.set("defType", "edismax");

QueryResponse response = solr.query(query);
SolrDocumentList results = response.getResults();
for (int i = 0; i < results.size(); ++i) {
  System.out.println(results.get(i));
}
}

线程“ main”中的异常java.lang.NoClassDefFoundError:org / apache / http / NoHttpResponseException

运行代码时,您在类路径中缺少NoHttpResponseException类。 要解决此问题,只需将apache httpcore-4.0.1.jar添加到您的类路径中。

我的第一个猜测可能是您丢失了httpcore-4.0.jar或使用了旧版本,因为它在4.0及以后版本中使用。

还要检查是否在部署路径中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM