仿牛客论坛Spring整合elasticsearch报错
Annotation-specified bean name 'discussPostRepository' for bean class [com.nowcoder.community.dao.elasticsearch.DiscussPostRepository] conflicts with existing, non-compatible bean definition of same name and class [org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactoryBean]
报错的原因是Spring Bean管理的对象名称重复了,在Spring扫描创建对象的过程中扫到了两个重名的注解。
修改方法:将elasticsearch这个包移到dao这个包之外,放在community这个包下。