[英]Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/http/NoHttpResponseException
Below code is for "Search using SolrJ". 以下代码用于“使用SolrJ进行搜索”。 When running code this error is shown.
运行代码时显示此错误。
IDE is netbean. 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));
}
}
Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/http/NoHttpResponseException
线程“ main”中的异常java.lang.NoClassDefFoundError:org / apache / http / NoHttpResponseException
You are missing NoHttpResponseException class in your classpath while running the code. 运行代码时,您在类路径中缺少NoHttpResponseException类。 To resolve this, just add apache
httpcore-4.0.1.jar
to your classpath. 要解决此问题,只需将apache
httpcore-4.0.1.jar
添加到您的类路径中。
My first guess would be that you are either missing the httpcore-4.0.jar or have an old version of it, since it used on 4.0 and after. 我的第一个猜测可能是您丢失了httpcore-4.0.jar或使用了旧版本,因为它在4.0及以后版本中使用。
Also check if you have it in the deployment path. 还要检查是否在部署路径中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.