springboot+elasticsearch 報錯

錯誤1: .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []java

次報錯是因爲配置文件application.properties裏面打開了一下注釋node

spring.data.elasticsearch.cluster-name=elasticsearch

spring.data.elasticsearch.cluster-nodes=127.0.0.1:9200

spring.data.elasticsearch.properties.path.logs=./elasticsearch/log
spring.data.elasticsearch.properties.path.logs=./elasticsearch/dataspring

錯誤2:包名不一致引發的報錯
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Test.ElasticSearchTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private inter.ArticleSearchRepository
app

當修改每一個包的名稱後,也即統一包名開頭後,成功運行。elasticsearch

成功運行截圖以下:3d

總結緣由:application.java啓動類必定要放在com包,也就是根目錄下的一個包下,不能放在和其餘三個包並列的包裏面,切記!!找了一夜的緣由。
還有下圖是變幻包視圖結構。blog

相關文章
相關標籤/搜索