'How to add multiple elastic client(index in different cluster) for ElasticsearchRepository

Tried to create two separate ElasticsearchRestTemplate using qualifier bean and gave different elasticsearchTemplateRef to ElasticsearchRepository , but its not working.

Getting error:

The bean 'elasticsearchTemplate', defined in class path resource [com/paytm/digital/search/ingestion/elastic/ElasticConfigK8.class], could not be registered. A bean with that name has already been defined in class path resource [com/paytm/digital/search/ingestion/elastic/ElasticConfig.class] and overriding is disabled.\n\nAction:\n\nConsider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition- Cannot register bean definition



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source