现象

springboot 引用的 spring-boot-starter-parent 版本为2.3.2.RELEASE
由于es集群版本在2.X 所以引入elasticsearch 版本为 2.4.6
项目启动提示:

  1. ***************************
  2. APPLICATION FAILED TO START
  3. ***************************
  4. Description:
  5. An attempt was made to call a method that does not exist. The attempt was made from the following location:
  6. com.nuonuo.ic.migrationcore.config.EsUtil.init(EsUtil.java:107)
  7. The following method did not exist:
  8. org.elasticsearch.common.settings.Settings.settingsBuilder()Lorg/elasticsearch/common/settings/Settings$Builder;
  9. The method's class, org.elasticsearch.common.settings.Settings, is available from the following locations:
  10. jar:file:/D:/maven/repository/org/elasticsearch/elasticsearch/7.6.2/elasticsearch-7.6.2.jar!/org/elasticsearch/common/settings/Settings.class
  11. The class hierarchy was loaded from the following locations:
  12. org.elasticsearch.common.settings.Settings: file:/D:/maven/repository/org/elasticsearch/elasticsearch/7.6.2/elasticsearch-7.6.2.jar
  13. Action:
  14. 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版本
1646015866(1).jpg
进而发现这里的es版本是 7.6.2 。
导出此 问题已经找到
也可以用 mvn dependency:tree -Dverbose -Dincludes=org.elasticsearch:elasticsearch (后续发现的快捷方式)

问题处理

方法一:

注释2.3.2.RELEASE,引用进行springboot版本的依赖管理 (多模块项目未起效)

方法二:直接引入springboot对应的es版本

不符合我的场景

方法三:直接将es的版本写入引用中不在使用 管理

后续发现不生效需要将es 的版本号在核心程序的 中,来覆盖springboot自身的版本