Annotating a main class with enable elasticsearch repositories in Spring Data Elasticsearch

I've got a question regarding Spring Data Elasticsearch best practices using the EnableElasticsearchRepositories annotation. We've been working on writing a common Elasticsearch library to avoid repeating the same boilerplate configuration code, but we were tripped up by what to do with the EnableElasticsearchRepositories annotation.

I've read that the annotation can go on either a configuration class or on the main application class, which would be preferred as we could keep the Elasticsearch configuration common while keeping the repositories in the project. While I've seen both used in examples, it seems more common to annotate the configuration class. I haven't been able to find anything that says annotating the main class is wrong or undesirable. We also successfully tested with the annotated main class with tests that had passed before, so there doesn't seem to be anything functionally wrong or weird.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.