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: []

次報錯是由於配置文件application.properties里面打開了一下注釋

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/data

錯誤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

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

成功運行截圖如下:

總結原因:application.java啟動類一定要放在com包,也就是根目錄下的一個包下,不能放在和其他三個包並列的包里面,切記!!找了一晚上的原因。
還有下圖是變幻包視圖結構。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM