问题描述
项目启动报错信息如下:
Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.kungeek.cpp.fssc.MdataApplication];
nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException:
Annotation-specified bean name 'receiptService' for bean class
[com.xxx.service.receipt.ReceiptService] conflicts with existing, non-compatible bean definition of same name and class
[com.xxx.service.budget.apply.accesory.ReceiptService]
原因分析:
提示:这里填写问题的分析:
spring IOC解析注解到bean池中,扫描到的类名相同但是包不相同,就会出现上面错误。
看最后两行内容:
[com.xxx.service.receipt.ReceiptService]
[com.xxx.service.budget.apply.ReceiptService]
解决方案:
- 修改包的名称,或者删除一个包
- @Service(value = “重命名”)