1. 程式人生 > >Spring boot 啟動報錯 'elasticsearchTemplate' that could not be found.

Spring boot 啟動報錯 'elasticsearchTemplate' that could not be found.

Spring boot 啟動報錯

(a)異常資訊

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-10-20 11:40:49.252 ERROR 3928 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field wayBillRepository in com.czxy.crm.service.stansit.DeliveryInfoService required a bean named 'elasticsearchTemplate' that could not be found.


Action:

Consider defining a bean named 'elasticsearchTemplate' in your configuration.

(b)異常原因

因為啟動配置中(application.properties) 缺少加有關elasticsearch的配置 如下 加入就好了

spring.data.elasticsearch.repositories.enabled = true
spring.data.elasticsearch.cluster-nodes =127.0.0.1:9300
/**註釋*/
有時此模組專案中並沒有使用elasticsearch  但是pom.xml  中依賴其他模組,其模組中有使用elastic search 所以導致報錯,此時就給他兩行配置就好了,何必糾結