欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

整合elasticsearch-rest-high-level-client报错nested exception is java.lang.NoSuchFieldError:IGNORE_DEPREC

程序员文章站 2022-03-07 11:17:54
报错信息:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restHighLevelClient' defined in class path resource [com/whf/search/config/ElasticSearchConfig.class]: Bean instantiation via factory method failed; nested exce...

报错信息:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restHighLevelClient' defined in class path resource [com/whf/search/config/ElasticSearchConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'restHighLevelClient' threw exception; nested exception is java.lang.NoSuchFieldError: IGNORE_DEPRECATIONS
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	...........
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'restHighLevelClient' threw exception; nested exception is java.lang.NoSuchFieldError: IGNORE_DEPRECATIONS
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	... 42 common frames omitted
Caused by: java.lang.NoSuchFieldError: IGNORE_DEPRECATIONS
	at org.elasticsearch.client.RestHighLevelClient.<clinit>(RestHighLevelClient.java:1906) ~[elasticsearch-rest-high-level-client-7.9.3.jar:7.9.3]
	at com.whf.search.config.ElasticSearchConfig.restHighLevelClient(ElasticSearchConfig.java:22) ~[classes/:na]
	at com.whf.search.config.ElasticSearchConfig$$EnhancerBySpringCGLIB$$cdc49e5a.CGLIB$restHighLevelClient$0(<generated>) ~[classes/:na]
	at com.whf.search.config.ElasticSearchConfig$$EnhancerBySpringCGLIB$$cdc49e5a$$FastClassBySpringCGLIB$$2f71c5f0.invoke(<generated>) ~[classes/:na]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	..............

工程依赖:

1)SpringBoot 2.1.10

2)elasticsearch-rest-high-level-client 7.9.3

查看maven依赖发现实际引入依赖:

org.elasticsearch:elasticsearch:6.4.3
org.elasticsearch.client:elasticsearch-rest-client:6.4.3

整合elasticsearch-rest-high-level-client报错nested exception is java.lang.NoSuchFieldError:IGNORE_DEPREC

排查:

1)进入spring-boot-starter-parent依赖

整合elasticsearch-rest-high-level-client报错nested exception is java.lang.NoSuchFieldError:IGNORE_DEPREC

2)进入spring-boot-dependencies

整合elasticsearch-rest-high-level-client报错nested exception is java.lang.NoSuchFieldError:IGNORE_DEPREC

3) 搜索elastic 发现SpringBoot默认的elasticsearch版本是6.4.3

整合elasticsearch-rest-high-level-client报错nested exception is java.lang.NoSuchFieldError:IGNORE_DEPREC

解决:pom文件指定elasticsearch版本,搞定

整合elasticsearch-rest-high-level-client报错nested exception is java.lang.NoSuchFieldError:IGNORE_DEPREC

本文地址:https://blog.csdn.net/weixin_41645232/article/details/110287188

相关标签: issues record