1.首先是无法加载SpringBoot的上下文,我们只需在common依赖文件里面加上下面的依赖即可:
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-context -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-context</artifactId>
<version>3.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-commons -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
<version>3.1.1</version>
</dependency>
2.之后再启动项目,我们会发现报错 Error creating bean with name ‘esRestClient’ defined in class path resource
这个就涉及到没有添加server依赖以及版本冲突的问题了
笔者这里用的基本都是最新的版本,与视频里面老师讲解的版本不太一样,所以这里附上解决办法:文章来源:https://www.toymoban.com/news/detail-524467.html
<!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.17.6</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.17.6</version>
</dependency>
我这里是把server的依赖添加进来,然后更改server以及client的版本和SpringBoot2.6.4的版本与之对应
3. 好了,我们再启动项目,已经可以完美运行:
文章来源地址https://www.toymoban.com/news/detail-524467.html
到了这里,关于谷粒商城P125SpringBoot整合ES报错Failed to load ApplicationContext的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!