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

相关文章
相关标签/搜索