Hi platform team,
Using SpringData Elasticsearch, I had the implementation of ElasticsearchRepository to communicate with an ElasticSearch API and it was working fine earlier. But after upgrade to Jmix version, it’s throwing the exception below.
APPLICATION FAILED TO START
Description:
The bean ‘ESAuditLogRepo’, defined in service.elasticsearch.ESAuditLogRepo defined in @EnableElasticsearchRepositories declared on ElasticsearchRepositoriesRegistrar.EnableElasticsearchRepositoriesConfiguration, could not be registered. A bean with that name has already been defined in service.elasticsearch.ESAuditLogRepo defined in @EnableJmixDataRepositories declared on BootJmixRepositoriesRegistrar.EnableJmixDataRepositoriesConfiguration and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
I already figured out the root cause my self. Spring takes care of the bean creation based on the declaration of the 2 annotation: EnableElasticsearchRepositories and EnableJmixDataRepositories
Look like Jmix also tried to scan all the Spring repo interface and instantiate the bean then lead to the conflict.
Googled around and found 2 solution so far:
1/ Allow bean overriding by
spring.main.allow-bean-definition-overriding=true
2/ Try to exclude the package like:
@EnableJmixDataRepositories(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = ESAuditLogRepo.class))
I don’t know well how the DataRepositories implemented internally inside Jmix, need to consult from JMIX team on which would be a better approach.
And is it possible for Jmix to just scan all the Repo defined by Jmix core or at least a configurable flag to do so?
Hope to hear from team soon. Thanks