问题描述项目使用solr 作为检索服务器,我在pom.xml 文件中添加solr 客户端版本为:solr-solrj-4.10.1,默认引入apache httpcore(4.3)/apache httpclient(4.5.3)版本。程序执行相关索引数据添加时提示如下错误信息:
java.lang.NoClassDefFoundError: org/apache/http/message/TokenParser
我检查了apache httpcore 版本中缺失没有发现TokenParser 类文件。
解决方法:移除solr-solrj-4.10.1 关联apache httpcore(4.3)/apache httpclient(4.5.3) jar ,新增依赖apache httpclient(4.5.13) jar 包版本。
pom.xml 配置文件如下:
<!-- solr 客户端集成 -->
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>4.10.1</version>
<exclusions>
<exclusion>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
<exclusion>
<artifactId>httpcore</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>