Spring启动异常之ConflictingBeanDefinitionException: Annotation-specified bean name ‘XXXXXService‘

问题描述

项目启动报错信息如下:

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]

解决方案:

  1. 修改包的名称,或者删除一个包
  2. @Service(value = “重命名”)

版权声明:本文为ss300400a原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。