您现在的位置是: 首页 > 后端开发 > Java SpringBoot 集成 Elasticsearch 7.8.1 出现错误 Factory method 'elasticsearchRestHighLevelClient' threw exception; nested exception is java.lang.NoSuchFieldError: IGNORE_DEPRECATIONS
SpringBoot 集成 Elasticsearch 7.8.1 出现错误 Factory method 'elasticsearchRestHighLevelClient' threw exception; nested exception is java.lang.NoSuchFieldError: IGNORE_DEPRECATIONS
2020-09-15 【Java】 5922人已围观 10796次浏览
简介SpringBoot 集成 Elasticsearch 7.8.1 出现错误 FactorySpringBoot 集成 Elasticsearch 7.8.1 出现错误 Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'elasticsearchRestHighLevelClient' threw exception; nested exception is java.lang.NoSuchFieldError: IGNORE_DEPRECATIONS method 'elasticsearchRestHighLevelClient' threw exception; nested exception is java.lang.NoSuchFieldError: IGNORE_DEPRECATIONS
由于项目中大量用到了搜索,如果全部使用数据库本身的模糊查询,效率是很低的,所以想到在项目中集成 Elasticsearch 来专用搜索
之前项目中,引用的版本是 6.8.8
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.8.8</version>
</dependency>
但是考虑到 Elasticsearch 目前已经升级到 7.8.X 了,这里想尝试一下新版本,使用 docker 搭建好服务,配置好 ik 分词后,项目引用 7.8.1 版本的 elasticsearch-rest-high-level-cliet
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.8.1</version>
</dependency>
然后启动项目,不出意外是报错了
Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'elasticsearchRestHighLevelClient' threw exception; nested exception is java.lang.NoSuchFieldError: IGNORE_DEPRECATIONS
根据提示内容,想到可能是缺少依赖(版本是 6.8.8 时,这样引用是没错的,也有可能是项目中已经包含了必要的引用,但配置文件中没写明)
之后查看下面两文档发现,必要的引用还有一个客户端版本,也就是 elasticsearch 的客户端
https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-high-level-client/7.8.1
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-compatibility.html
根据说明,修改 pom.xml 文件
<!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-high-level-client -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.8.1</version>
</dependency>
之后 maven reload ,重新运行项目,错误解决。果然问题是出在了缺少依赖上
很赞哦! (0)
点击排行
- Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR DISABLE You can't write or read against a disable instance
- Debian apt 使用国内镜像
- RocketMQ 出现 sendDefaultImpl call timeout 问题
- 类 BASE64Decoder 程序包 sun.misc 找不到符号
- SpringBoot @NotBlank 不生效问题
- 记一次 Mybatis-Plus 自动填充无效问题解决
- SpringBoot 2.x 文件上传出现 The field file exceeds its maximum permitted size of 1048576 bytes
- nuxt 项目完整部署方案
站长推荐
猜你喜欢
- SqlServer 优化技巧
- 【代码片段】MySQL新建表添加基础字段
- sentinel directive while not in sentinel mode 问题解决
- Laravel Dingo/api 出现 The version given was unknown or has no registered routes.报错
- Docker 批量操作命令
- Windows CMD 常用命令
- 在使用Flutter进行网络请求时,使用Dio访问https地址出现unable to get local issuer certificate错误
- 删除Git仓库所有历史提交记录,成为一个干净的仓库
- Zookeeper 找不到或无法加载主类 org.apache.zookeeper.server.quorum.QuorumPeerMain
- mybatis中大于等于小于等于的写法