2017-03-06 77 views
0

我是Spring引導和彈性搜索的新成員。使用此參考https://github.com/VanRoy/spring-data-jest使用aws elasticsearch進行連接。現在連接工作正常,我可以執行操作。我想創建自定義存儲庫(基本上想要使用聚合)並使用ElasticsearchTemplate,它給出以下錯誤日誌:使用客戶端客戶端進行總和聚合

com.example.abcRepositoryImpl中的字段elasticsearchTemplate需要一個類型爲'org.springframework.data.elasticsearch'的bean。 core.ElasticsearchTemplate'找不到。 - Bean方法「elasticsearchTemplate」不加載,因爲自動配置「ElasticsearchDataAutoConfiguration」被排除

操作:

考慮重新審視上述條件或限定類型「org.springframework.data.elasticsearch.core的豆。 ElasticsearchTemplate'在您的配置。

我將如何解決問題。你的幫助將非常可觀。

在此先感謝

+0

我得到了解決。我們可以使用JestClient接口並執行操作。例如:@Autowired \t JestClient客戶端; – Kumar

回答

0

在你的主應用程序類文件中定義一個bean像下面

@Bean 
public JestElasticsearchTemplate elasticsearchTemplate(JestClient client) { 
    return new JestElasticsearchTemplate(client); 
}