我使用的是solr-6.4.0。我能够安装Solr,创建一个名为" core1"的集合,使用post命令索引文件,并且还能够通过浏览器实例从Solr搜索数据。我使用以下URL访问Solr:http://localhost:8983/solr/core1。 现在,当我尝试通过eclipse访问上述URL时,它会出现以下错误:
[main] ERROR SolrQuery - Generic Exception : Server at http://localhost:8983/solr was not found (404).
org.apache.solr.client.solrj.SolrServerException: Server at http://localhost:8983/solr was not found (404).
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:402)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:221)
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:89)
at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:311)
at SolrDataDAO.queryData(SolrDataDAO.java:36)
at SolrQuery.testQueryData(SolrQuery.java:102)
at SolrQuery.main(SolrQuery.java:74)
Exception in thread "main" java.lang.NullPointerException
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at SolrQuery.main(SolrQuery.java:89)
这是我正在运行的代码:
public HttpSolrServer getSolrConnection() throws Exception
{
HttpSolrServer solrServer = null;
try {
// configure a server object with actual solr values.
if (solrServer == null) {
solrServer = new HttpSolrServer("http://localhost:8983/solr/core1");
solrServer.setParser(new XMLResponseParser());
solrServer.setSoTimeout(5000);
solrServer.setConnectionTimeout(5000);
}
} catch (Exception exc) {
logger.error(" Exception in getting Solr Connection: "
+ exc.getMessage());
exc.printStackTrace();
}
return solrServer;
}
我在solr 4.5.0中使用了相同的代码,它非常好。但升级后它无法正常工作。请告诉我更新/包含的内容(jar文件,如果有的话)。 谢谢