现象
springboot 引用的 spring-boot-starter-parent 版本为2.3.2.RELEASE
由于es集群版本在2.X 所以引入elasticsearch 版本为 2.4.6
项目启动提示:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.nuonuo.ic.migrationcore.config.EsUtil.init(EsUtil.java:107)
The following method did not exist:
org.elasticsearch.common.settings.Settings.settingsBuilder()Lorg/elasticsearch/common/settings/Settings$Builder;
The method's class, org.elasticsearch.common.settings.Settings, is available from the following locations:
jar:file:/D:/maven/repository/org/elasticsearch/elasticsearch/7.6.2/elasticsearch-7.6.2.jar!/org/elasticsearch/common/settings/Settings.class
The class hierarchy was loaded from the following locations:
org.elasticsearch.common.settings.Settings: file:/D:/maven/repository/org/elasticsearch/elasticsearch/7.6.2/elasticsearch-7.6.2.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.common.settings.Settings
明显看出项目引入的版本是 7.6.2 不是自己引入的2.4.6
问题猜想
1、有没有可能是其他地方引入了高版本
2、是否springboot 自身版本向上兼容
排查
检查项目中是否有es其他引用。 经过排查未发现其他地方的引用
排查springboot自己版本中中的es
发现springboot 2.3.2.RELEASE 中有自带的es版本
进而发现这里的es版本是 7.6.2 。
导出此 问题已经找到
也可以用 mvn dependency:tree -Dverbose -Dincludes=org.elasticsearch:elasticsearch (后续发现的快捷方式)
问题处理
方法一:
注释
方法二:直接引入springboot对应的es版本
不符合我的场景
方法三:直接将es的版本写入引用中不在使用 管理
后续发现不生效需要将es 的版本号在核心程序的