使用Solrj连接到solr索引。使用jar solr-solrj-3.6.1.jar ,我在下面添加了maven依赖
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>3.6.1</version>
</dependency>
我看到CommonsHttpSolrServer已被弃用,因此使用了HttpSolrServer。在运行期间我得到以下错误, 线程“main”中的异常java.lang.NoClassDefFoundError:org / apache / http / client / HttpClient
仅添加 solr-solrj-3.6.1.jar 是不够的?我是否应该添加更多依赖项?我也试过添加httpclient 4.1,它开始要求org / apache / http / HttpRequestInterceptor。
答案 0 :(得分:0)
将此包添加到您的maven依赖项:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.1</version>
</dependency>
答案 1 :(得分:0)
添加了以下依赖项以实现此功能
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.8</version>
</dependency>
答案 2 :(得分:0)
我的solrj简单项目使用以下依赖项:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
</dependencies>
之间,Maven可以自动下载它们(例如,我在NetBeans中启动了Maven的Java应用程序,然后只添加了依赖项)。另外,我只需要下载commons-logging 1.1.3(http://commons.apache.org/proper/commons-logging/download_logging.cgi)库。您可以在此处阅读有关库和依赖项的更多信息:(http://wiki.apache.org/solr/Solrj)。